Home Forums WinForms controls Xceed Grid for WinForms Using CellValueChanged in a bound grid Reply To: Using CellValueChanged in a bound grid

User (Old forums)
Post count: 23064

I’ve tracked down the issue. It is a bug in the implementation of the grid. When you modify rows directly in a bound System.Data.DataTable only the CellValueChanged event of a Xceed.Grid.DataRow is triggered and not the ValueChanged event of a Xceed.Grid.DataCell

See the following code for proof:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace XceedTest
public partial class Form1 : Form
DataSet ds;

public Form1()

ds = new DataSet();

DataTable dt = new DataTable(“pills”);

dt.Columns.Add(“Id”, typeof(int));
dt.Columns.Add(“state”, typeof(string));

dt.Rows.Add(new object[] { 0, “red” });
dt.Rows.Add(new object[] { 1, “blue” });


this.gridControl1.AddingDataRow += new Xceed.Grid.AddingDataRowEventHandler(gridControl1_AddingDataRow);
this.gridControl1.DataSource = ds.Tables[“pills”];

void gridControl1_AddingDataRow(object sender, Xceed.Grid.AddingDataRowEventArgs e)
e.DataRow.Cells[“state”].ValueChanged += new EventHandler(Form1_ValueChanged);
// e.DataRow.CellValueChanged += new EventHandler(DataRow_CellValueChanged); // comment the line above and uncomment this line to check that the row’s event handler reacts on underlying changes

void DataRow_CellValueChanged(object sender, EventArgs e)
Debug.WriteLine(“recieved event from data row”);

Xceed.Grid.DataRow r = sender as Xceed.Grid.DataRow;

if (r.Cells[“state”].Value.ToString() == “red”)
r.BackColor = Color.Red;
r.BackColor = Color.White;

void Form1_ValueChanged(object sender, EventArgs e)
Debug.WriteLine(“recieved event from cell”);
Xceed.Grid.DataCell cell = sender as Xceed.Grid.DataCell;

if (cell.Value.ToString() == “red”)
cell.ParentRow.BackColor = Color.Red;
cell.ParentRow.BackColor = Color.Blue;

private void button1_Click(object sender, EventArgs e)
ds.Tables[“pills”].Rows[0][“state”] = “blue”;

private void button2_Click(object sender, EventArgs e)
ds.Tables[“pills”].Rows[0][“state”] = “red”;


Imported from legacy forums. Posted by twi (had 1144 views)