Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2320
CellChange event problems
posted

I have a UltraWinGrid that has a checkbox inside it.

I have logic in the grids "CellChange" event to perform some logic when the user checks or unchecks the checkbox.

When the user checks or unchecks the checkbox, the "CellChange" event is fired.  But, when I try to set it programmatically it doesn't seem to fire the event.

I added a context menu with an option to CheckAll selected grid rows.

In the context menu click event, I iterate on all selected rows and set each columns value to true/false like this..

foreach (UltraGridRow selectedRow in gridBusSysItems.Selected.Rows)

  //selectedRow.Cells[ColumnName].Value = bChecked;

  grid.Rows[selectedRow.Index].Cells[ColumnName].Value = bChecked;

 

}

Both lines of code in the foreach appear to properly set the checkbox.  However, the grids "CellChange" event does not appear to get fired when I change the value programmatically.

Any help would be greatly appreciated. 

 

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi,

        This is something of a gray area in control design...

        When the user changes a value in a cell, you, the programmer, need an event to tell you that this happened. But when the value is changed in code, you know that you changed it, so you really don't need an event.

        Sometimes, of course, events do fire when you make changes in code, but there's really not hard and fast rule about when events are and are not fired in response to code changes. 

        What I would recommend in this case is that you take whatever code you have in the CellChange event and factor it out into another method. You can then call that method from the CellChange event and also from within your loop or anywhere else you set the value of a cell in the checkbox column.  

Children
No Data