Hi,
I''m trying to update a field on my form when a the value of a ComboBox in my virtual grid is changed.
I couldn''t find any event analogous to SelectionChangeCommitted and the CurrentCellCloseDropDown event isn''t 100% reliable for this as some of my users type their value rather than use the mouse to select it from the drop down.
How can I go about either capturing when the value is changed prior to the cell being exited or better yet, cause a change of the selected value to be saved immediately (performance shouldn''t be an issue, the list is 4 items).
AD
Administrator
Syncfusion Team
August 14, 2006 04:11 AM UTC
Hi Rich,
You can access the GridComboBoxCellRenderer and can subscribe the SelectedValueChanged event to detect the selected item in a ComboBox cell.
//Form Load....
GridComboBoxCellRenderer cr = this.grid.CellRenderers["ComboBox"] as GridComboBoxCellRenderer;
if( cr != null)
{
cr.ListBoxPart.SelectedValueChanged+=new EventHandler(ListBoxPart_SelectedValueChanged);
}
private void ListBoxPart_SelectedValueChanged(object sender, EventArgs e)
{
ListBox list = sender as ListBox;
DataRowView row = list.SelectedItem as DataRowView;
if( row != null)
{
Console.WriteLine(row[1]);
}
}
Best Regards,
Haneef
RI
Rich
August 14, 2006 01:33 PM UTC
Thanks Haneef,
Exactly what I needed. Now, how would I force a commit of the selected value at that point? And do you see any problem with that approach?
Thanks,
Rich
ps - since I''m asking -
I have some columns for displaying currency. Some are editable, some are not. The users want decimal places to 5 places but they only want to see the significant places beyond 2 places.
For example,
2 should show as 2.00
2.5 should show as 2.50
2.55 should show as 2.55
2.551 should show as 2.551
2.55100 should show as 2.551
How can I achieve this?
AD
Administrator
Syncfusion Team
August 16, 2006 06:05 AM UTC
Hi Rich,
Issue 1:
To commit the current cell change in a grid, you need to call the CurrentCell.EndEdit and Binder.EndEdit method in ListBoxPart''s SelectedValueChanged event.
Issue 2:
The DrawCellDisplayText event can be handled and there the cell value can be parsed and the resultant simple string can be set to the e.DisplayText. Please refer the attached sample for more details.
Here is a Sample.
http://www.syncfusion.com/Support/user/uploads/FormattedText_f9b86fa0.zip
Let me know if this helps.
Best Regards,
Haneef
AD
Administrator
Syncfusion Team
August 16, 2006 12:22 PM UTC
Thanks Haneef,
I had settled on CurrentCell.ConfirmChanges() but I will switch to using CurrentCell.EndEdit().