Home Forums WinForms controls Xceed Grid for WinForms loosing selected value when changing cells Reply To: loosing selected value when changing cells

User (Old forums)
Member
Post count: 23064

Hi Tommy,

Thank you for your reply. I tried using the code you suggested and it produces the same results as what I was doing before. It works, but when I select a value from the colorCombo and then leave the cell, it looses the value that I selected. Here is what my code looks like now:

<code>
colParam = new Xceed.Grid.Column(strCellName, typeof(Color));

colorCombo = new Xceed.Grid.Editors.GridComboBox();

// create new instance of color
System.Drawing.Color myColor = new System.Drawing.Color();
// Get the type of instance
Type colorType = myColor.GetType();

foreach (PropertyInfo p1 in colorType.GetProperties(BindingFlags.Public | BindingFlags.Static))
{
colorCombo.Items.Add(p1.Name);
}

colParam.CellEditor = colorCombo;
colParam.CellViewer = colorCombo;
gridControl1.Columns.Add(colParam);

myRow.Cells[strCellName].LeavingEdit += new Xceed.Grid.LeavingEditEventHandler(myCellValueChanged);

</code>

myCellValueChanged method:

<code>
private void myCellValueChanged(object sender, Xceed.Grid.LeavingEditEventArgs e)
{
Xceed.Grid.Cell cell = sender as Xceed.Grid.Cell;
Xceed.Grid.CellRow row = cell.ParentRow;
row.Cells[strCellName].Value = colorCombo.Text;
}
</code>

Am I missing anything else?

Thank you

Imported from legacy forums. Posted by Nathan (had 601 views)