Home Forums WinForms controls Xceed Grid for WinForms How do I subscribe to the events of each cell?

Viewing 1 post (of 1 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #17777 |

    Subscribing to the desired events for each cell in the DataRowTemplate will, once the grid is populated, also subscribe each cell in the grid to the same events. However, in order to do this, the grid’s DataSource must be set between calls to the BeginInit and EndInit methods.

    When binding the grid to a data source by setting the DataSource and DataMember properties or calling the SetDataBinding method during calls to BeginInit and EndInit, the column definitions (not their values) are still read from the data source. This allows you to subscribe each cell in the DataRowTemplate to the desired events. For example:

    VB.NET

    GridControl1.BeginInit()

    GridControl1.DataSource = DataSet11
    GridControl1.DataMember = “Orders”

    Dim cell As DataCell
    For Each cell in GridControl1.DataRowTemplate.Cells
        AddHandler cell.ValidationError, AddressOf Me.cell_ValidationError
    Next cell

    GridControl1.EndInit()

    C#

    gridControl1.BeginInit();

    gridControl1.DataSource = dataSet11;
    gridControl1.DataMember = “Orders”;

    foreach( DataCell cell in gridControl1.DataRowTemplate.Cells )
    {
        cell.ValidationError += new ValidationErrorEventHandler( this.cell_ValidationError );
    }

    gridControl1.EndInit(); 

    Imported from legacy forums. Posted by Xceed admin (had 1644 views)

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.