Home Forums WinForms controls Xceed Grid for WinForms Trouble with currentcellchanged event Reply To: Trouble with currentcellchanged event

User (Old forums)
Post count: 23064

Try this: keep a boolean variable initializingGrid (like your currentCell variable), and set it to false.
In LoadSomeData, you set the variable to true, before BeginInit, and set it to false after EndInit.
In gridControl1_CurrentCellChanged, you check the variable, and exit the method when the variable is true.

private Xceed.Grid.Cell currentCell = null;
private bool initializingGrid = false;

private LoadSomeData(DataTable T)
initializingGrid = true;
gridControl1.DataSource = T;
currentCell = null;
gridControl1.CurrentCellChanged +=new EventHandler(gridControl1_CurrentCellChanged);
initializingGrid = false;

private void gridControl1_CurrentCellChanged(object sender, EventArgs e)
if (initializingGrid) return;
int maxHeight = 100;
Xceed.Grid.Cell newCell = gridControl1.CurrentCell;
newCell.BackColor = Color.LemonChiffon;
newCell.ParentRow.Height = Math.Min(maxHeight,newCell.GetFittedHeight(Xceed.Grid.AutoHeightMode.AllContent));
if (currentCell != null)
currentCell.BackColor = currentCell.AmbientParent.BackColor;
currentCell.ParentRow.Height = currentCell.GetFittedHeight(Xceed.Grid.AutoHeightMode.Minimum);
currentCell = newCell;

Imported from legacy forums. Posted by Tommy (had 3292 views)