We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Trying to override the saving of a combobox cell in GGC

I had a table with an int column that represents an Id. In lieu of displaying a drop down of Ids, I want to display a list of strings that describe what the Ids represent. I've overriden the QueryCellStyleInfo and SaveCellFormattedText event handlers to try to deal with this, but for some reason, the changes don't persist when I click out of the cell I'm editing. Any ideas?

Thanks!

Eric

Test63.zip

1 Reply

AD Administrator Syncfusion Team December 15, 2006 05:39 AM UTC

Hi Eric,

Use the ValueMember and DisplayMember property of the ComboBox cell to resolve this. Here is a code snippet to show this.

DataTable comboTable = new DataTable("DropDownCombo");
comboTable.Columns.Add("ID",typeof(int));
comboTable.Columns.Add("Item",typeof(string));

for(int i = 0 ;i <5;i++)
{
DataRow dr= comboTable.NewRow();
dr[0] = i;//ValueMember value..
dr[1] = "Item" + i;//DisplayMemberValue
comboTable.Rows.Add(dr);
}
comboTable.AcceptChanges();

gridGroupingControl1.TableDescriptor.Columns["Id1"].Appearance.AnyRecordFieldCell.CellType = "ComboBox";
gridGroupingControl1.TableDescriptor.Columns["Id1"].Appearance.AnyRecordFieldCell.DataSource = comboTable;
gridGroupingControl1.TableDescriptor.Columns["Id1"].Appearance.AnyRecordFieldCell.ExclusiveChoiceList = true;

//That hold the cell text to be displayed in a cell.
gridGroupingControl1.TableDescriptor.Columns["Id1"].Appearance.AnyRecordFieldCell.DisplayMember = "Item";
//That hold the text to be stored in a cell.
gridGroupingControl1.TableDescriptor.Columns["Id1"].Appearance.AnyRecordFieldCell.ValueMember = "ID";

Here is a modified sample.
ModifiedTest.zip

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon