Home Forums WinForms controls Xceed Grid for WinForms DataRowsChanged Event

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

    Hi,

    I have a data bound grid and when updating the data in the data set I want to be able to change some formatting in the grid. The only problem is that when the DataRowsChanged event handler fires then you can’t find out the data row that changed.

    If you can I would really like to know how put putting it as part of the event arguments that are passed to the event handler would be nice, so you can find out what it is.

    I tried the ValueChanged event for the individual cell that controls the formatting but that doesn’t fire if the value changes after it is initially loaded! Surely there is a bug there as that would have been the better implementation that when the value of an individual cell changes you can get it’s parent row but it doesn’t work when changing bound data.

    Chris

    Imported from legacy forums. Posted by Chris (had 3044 views)

    User (Old forums)
    Member
    Post count: 23064

    Try this:<code>grid.DataRowTemplate.CellValueChanged += new EventHandler(grid_DataRow_CellValueChanged);
    private void grid_DataRow_CellValueChanged(object sender, EventArgs e) {
    Xceed.Grid.DataRow row = sender as Xceed.Grid.DataRow;
    if (row != null) {
    // row is the DataRow that was modified
    }
    }</code>

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

    User (Old forums)
    Member
    Post count: 23064

    Although this is a very old topic, I have a question about this.

    I also tried to use the DataRowsChanged event and noticed then, that there is no chance to get the changed row. The CurrentRow property of the grid is a reference to the new row, but not to the edited row.

    The question is if there is a way to get the edited row in the DataRowsChanged event? Without this information the event is not very useful.

    The above-mentioned CellValueChanged event is not the right event for me, because I search for an event that is raised when leaving a edited row, not when leaving a edited cell.

    Imported from legacy forums. Posted by cmeyer1984 (had 550 views)

    User (Old forums)
    Member
    Post count: 23064

    Use the EditEnded event on the DataRowTemplate, and cast the sender to a DataRow in the event handler. This will give you access to the row that was just edited.

    e.g.:

    //In Form_Load

    dataRowTemplate1.EditEnded += new EventHandler(dataRowTemplate1_EditEnded);

    //Event handler

    private void dataRowTemplate1_EditEnded(object sender, EventArgs e)
    {
    Xceed.Grid.DataRow row = ( Xceed.Grid.DataRow )sender;
    }

    Imported from legacy forums. Posted by André (had 4034 views)

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