Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programmatically add Collection to Column Collection of DataGridView

Status
Not open for further replies.

eb24

Programmer
Dec 17, 2003
240
US
Here's my scenario: Work in a C# 2.0 environment with our view layer bound to a business logic layer of objects.

Here is what I'm attempting to do: Upon a form loading, user picks a value from a combobox and it brings back a collection of values. These values, I would like them to populate each row of a datagridview component. So let's say a user picks an item from the combobox that contains 3 values, so upon IndexChanged, the datagridview will display 3 rows. Oh, by the way, the datagridview will only have 2 columns - first column will be automatically populated by the collection above (3 values) and the right column, the user will be in charge of entering corresponding values. What I've done, is I'm able to loop through the collection brought back from above and then using the Rows.Add, I add each value to it, but I can't seem to know how to update the business object behind or when to set the datagridview's datasource. Not sure how to move forward - i.e. what events do I use, _AddingNew(), etc.?

Any advice will be greatly appreciated.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top