views:

15

answers:

1

Looking for an example of a usercontrol in a datagridview row using Windows forms. The Usercontrol would have multipe controls based on the business logic which depends on the the index of the row. Thanks

A: 

You cannot insert a user control directly into a row in the way you would like. Your only possiblity is to add a new column type. Your custom column implementation would act like the other columns in that when it enters Edit mode it can create a control (in your case an appropriate one for the index number) and then have it work inside the cell until the Edit mode is exited. The issue would be drawing the cell when not in Edit mode.

You can see the source code of the builtin columns by using the .NET Reflector tool or search the web for custom DataGridView columns as there are many implementations that give sample code you could use as a starting point.

Phil Wright