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

ggc combobox - setting selected item

Hi,

I managed to define a ggc combobox column using the following code

======================================
StringCollection rows = new StringCollection();
ggc1.TableDescriptor.Columns["Col1"].Appearance.AnyRecordFieldCell.CellType = "ComboBox";
ggc1.TableDescriptor.Columns["Col1"].Appearance.AnyRecordFieldCell.DataSource = rows;
rows.Add("item1");
rows.Add("item2");
...
======================================

I now need to select an item programatically, but I couldn't find any property that relates to the Selected-Index and everything I tried has failed.


(my product version is 4.4.0.5.51)



Thanks in advance.

1 Reply

RA Rajagopal Syncfusion Team April 25, 2007 05:24 PM UTC

Hi Ryan,

The grid does not track ''the selected index''. The only thing its knows is the cell value. The selected index is only around when the dropdown is visible.
You can use the code below in the TableControlCurrentCellCloseDropDown/TableControlCurrentCellShowedDropDown to get at the selected index.

void gridGroupingControl1_TableControlCurrentCellCloseDropDown(object sender, GridTableControlPopupClosedEventArgs e)
{
GridCurrentCell cc = e.TableControl.CurrentCell;
GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer;
if (cr != null)
{
Console.WriteLine(cr.ListBoxPart.SelectedIndex);
}
}

But when there is no combobox dropped or about to be dropped or closed, then there is no selectedindex available.

Let us know if you need any further information.
Regards,
Rajagopal

Loader.
Live Chat Icon For mobile
Up arrow icon