Home Forums WinForms controls Xceed Grid for WinForms ValueChanged not called for SummaryCell

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #16008 |

    I have created a SummaryCell that is used to sum up the values in a given column. I want to set the color of this cell depending on it’s value (green when positive, red when negative). However, the event ValueChanged is not fired when the SummaryCell is updated. Is this by design?

    The only solution I can come up with is listen for the ValueChanged event on every cell in the column, and then check the SummaryCell’s value within that callback. However, I am unsure when the SummaryCell’s value is updated (before or after the cell’s ValueChanged callback). However, it would be best if the SummaryCell invoked the ValueChanged event.

    Any help would be appreciated. Am I missing something?

    Thanks,

    John

    Imported from legacy forums. Posted by John (had 1957 views)

    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)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.