Home Forums WinForms controls Xceed Grid for WinForms (DropDown) combo box problem Reply To: (DropDown) combo box problem

User (Old forums)
Member
Post count: 23064

For any that are interested:

Here is what I did to make it work.

First, I declare my cell viewers and editors somewhere after the InitializeComponent, but outside of any other handlers or methods. (in the public class level) This will make the editors, as wee as any other variables I create here, available from anywhere in my code.

Case 1: Combo Box filled by using MyEditor.Items.Add(item)

in the EditLeft event handler for the Cell I am using the combo box in, access the combo box in this way:

foreach (Xceed.Grid.DataRow row in MyGrid.SelectedRows)
{
for (int i = 0; i < MyEditor.Items.Count; ++i)
{
if (MyEditor.Text == MyEditor.Items[i].ToString())
{
row.Cells[“NameOfCell”].Value = MyEditor.Text;
}
}
}

Case 2: Combo Box is filled with a dataset:

in the EditLeft event handler for the Cell I am using the combo box in, access the combo box in this way:

foreach (Xceed.Grid.DataRow row in MyGrid.SelectedRows)
{
for (int i = 0; i < dsMyDataset.Tables[“tableName”].Rows.Count; ++i)
{
if (MyEditor.Text == dsMyDataset.Tables[“tableName”].Rows[i][“ColumnName”].ToString())
{
row.Cells[“NameOfCell”].Value = MyEditor.Text;
}
}
}

Hope this helps any who still need a solution for this.
Ken

Imported from legacy forums. Posted by KenG (had 3645 views)