Changing datasource of Combobox at runtime

How can I change the datasource of a combobox cell when is clicked. I tried the following code without success: private void GDBG_CurrentCellActivated(object sender, System.EventArgs e) { if (GDBG.CurrentCell.ColIndex == 4) { GridComboBoxCellRenderer cr=(GridComboBoxCellRenderer)GDBG.CurrentCell.Renderer; CurrencyManager cm = (CurrencyManager) this.BindingContext[GDBG.DataSource]; DataRow row = (DataRow) ((DataRowView) cm.Current).Row; string ownertype = Convert.ToString(row["Descr"]); string filter = "ContactGroup LIKE ''" + ownertype + "''"; oDS.Tables[2].Rows.Add(oDS.Tables[1].Select(filter)); cr.ListBoxPart.DataSource = oDS.Tables[2]; cr.ListBoxPart.ValueMember = "ContactTypeKey"; cr.ListBoxPart.DisplayMember = "ContactTypeDescription"; }

2 Replies

AD Administrator Syncfusion Team February 22, 2006 06:19 AM UTC

Hi Kingsley, Setting the DataSource for a ComboBox type cell in the CurrentCellActivated event handler works fine. The DataSource can also be set in the CurrentCellShowingDropDown event handler. Please check whether the oDS.Tables[1].Select(filter) in your code returns any row. The DropDown list part wont be shown when the DataSource is empty. Regards, Calvin.


KI Kingsley February 23, 2006 03:15 PM UTC

You''re right, the problem is from the filter line. It''s ok now, Thanks >Hi Kingsley, > >Setting the DataSource for a ComboBox type cell in the CurrentCellActivated event handler works fine. The DataSource can also be set in the CurrentCellShowingDropDown event handler. Please check whether the oDS.Tables[1].Select(filter) in your code returns any row. The DropDown list part wont be shown when the DataSource is empty. > >Regards, >Calvin.

Loader.
Up arrow icon