|
I've spent a good couple of days trying to sort this one and read many many posts. However, I've not been able to find a specific solution and it has me baffled.
The (C#) scenario is this;
I have a DataGridView that has some cells as DataGridViewComboBoxCell. These have a fixed set of items from which the user can select. However, when populating the DataGridView programatically some of the DataGridViewComboBoxCell's may be loaded with values that are NOT in the DataGridViewComboBoxCell's items lists. I want to have the values showing in the table (albeit with the cell colour changed and the tooltip explaining that the value is invalid) so the user can see the 'bad' value and select the valid value from the drop down list.
Therefore, I dont want to add the 'bad' value to the dropdown list. All I want is for the DataGridViewComboBoxCell to display a value not in it's list (I can deal with the cell style/tooltip etc).
The nearest I've got so far is handling the DataError event that is raised. I ignore it, but (as others have said) the value shown gets changed to the first value in the Items list...
The DataGridView is bound to a DataTable, which is loaded from a file; no database binding. And the DataGridViewComboBoxCell list loaded when the DataGridView cell is created during a RowsAdded event.
I'm fast coming to the conclusion that the DataGridViewComboBoxCell is not going to do it for me, so the main question is; how have others resolved this?A custom control implementing IDataGridViewEditingControl (Which gets hairy, as i found while coding a Date selection control...) etc?
Thanks all (and many apologies if i HAVE missed the exact answer somewhere :-))
Vectis - Edited byvectis Tuesday, September 15, 2009 8:28 PMclarification
-
|