Home Forums WinForms controls Xceed Grid for WinForms ValueChanged not called for SummaryCell Reply To: ValueChanged not called for SummaryCell

Xceed Support
Member
Post count: 5658

The update of the SummaryCell value is one of the last thing done by the GridControl when it’s refreshed. In this regard, you need to subscribe to the Application.Idle event.

Here is a snippet that should help you get started:

<code>
private void Form1_Load( object sender, EventArgs e )
{
for( int j = 0; j < 4; j++ )
{
Column col = new Column( “Column”+j.ToString(), typeof(int) );
gridControl1.Columns.Add( col );
}

for( int i = 0; i < 20; i++ )
{
Xceed.Grid.DataRow row = gridControl1.DataRows.AddNew();
foreach( Cell cell in row.Cells )
{
cell.Value = i*10+10*cell.ParentColumn.Index;
}
row.EndEdit();
}

SummaryRow sumRow = new SummaryRow();
gridControl1.FixedFooterRows.Add( sumRow );

foreach( SummaryCell cell in sumRow.Cells )
{
cell.StatFunction = StatFunction.Sum;
if( ( int )cell.Value > 2200 )
cell.BackColor = Color.Green;
else
cell.BackColor = Color.Red;
}

dataRowTemplate1.CellValueChanged += new EventHandler( dataRowTemplate1_CellValueChanged );
}

void dataRowTemplate1_CellValueChanged( object sender, EventArgs e )
{
Application.Idle += new EventHandler( Application_Idle );
}

void Application_Idle( object sender, EventArgs e )
{
Application.Idle-=new EventHandler(Application_Idle);
SummaryRow sumRow = ( SummaryRow )gridControl1.FixedFooterRows[ 0 ];

foreach( SummaryCell cell in sumRow.Cells )
{
if( ( int )cell.Value > 2200 )
cell.BackColor = Color.Green;
else
cell.BackColor = Color.Red;
}
}
</code>

Imported from legacy forums. Posted by CharlesB (had 3087 views)