Reputation: 11423
I have the following case::
Before:
one Grid view ,,this grid view has two object data sources , bind each one of these sources in two separate states in my business logic.. every thing is okay..
After: i have to add one more column to my Grid view this column belongs to the first object data source but does not exist as a property in the second data source..
what i wanna is to do is ::using the same grid view with the two data sources instead of create another grid view with the same fields except the last added field..how to do some thing like this .how to exclude the last added field from grid view for the second object data source..
Upvotes: 0
Views: 4172
Reputation: 17448
You should be able to just add/remove the column from the DataGridView.Columns
collection depending on which data source you are bound to. When you bind to the source that needs the column, add it to the collection. When you bind to the other source, before binding, remove the column from the collection.
Here is a link about the Columns
collection http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.columns.aspx. Note the mention on the page that you can add/remove and obtain a count of columns by using the collection returned from the Columns
property.
Upvotes: 1