I'm currently playing around with ComboBox CellTypes and want to have control over what is happening to the Cell's value. This is what I do:
- Create an array of objects (ID/Name properties available) and assign to DataSource
- Set DisplayMember (Name) and ValueMember (ID)
- Set CellValue to the ID of the currently selected item
- Set ExclusiveChoiceList to true
This works like a charm. Now, I want to track changes to the selection:
- Trap CurrentCellChanged Event and read the new CellValue of the current cell.
This is where the problem starts:
The ComboBox Model/Renderers never ever set the CellValue/ControlValue. Only the ControlText will be changed. Looking through the Source Code of the Grid and the Models/Renderers show that the CellValue will only be used to initialize the current selection of the ComboBox. Thereafter CellValue/ControlValue won't be changed at all. I have created a workaround for this identifying the selected item by its label but I'd prefer getting either the selected index or the selected item's ID (ValueMember) which is actually what I was expecting the ComboBox Model/Renderer to do.
In case I'm missing something here, please let me know.
Thanks for your help
ADAdministrator Syncfusion Team November 27, 2002 05:11 AM
I don't think you are missing anything. We will modify our code allow you to easily get at the current control value as well as the current control text. Look for this change in the next update.
ADAdministrator Syncfusion Team December 2, 2002 11:07 AM
I had the same problem as Kai noted earlier.
As a workaround, if you register for "CellsChanged" event, you would get the changed value. Here is a snippet:
private void grid1_CellsChanged(object sender, Syncfusion.Windows.Forms.Grid.GridCellsChangedEventArgs e)
Console.WriteLine("Cells changed: " + e.Range);
int row = e.Range.Top;
int col = e.Range.Left;
// Note: Comboboxes does not emit the value until it looses focus
// adjust the following row/cols
if (col == 3 && (row == 9 || row == 11))
object newValue = grid1[row,col].CellValue;
Hope this helps.
KIKai IskeDecember 3, 2002 11:43 PM
thanks for the information. Will look into this. Maybe this is a hint to the Syncfusion guys as well, as the CellValue actually does get set before calling some Event Handlers.