Home Forums WinForms controls Xceed Grid for WinForms RemovingDataRow event

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

    Hi,

    I use the AddingDataRow event to add an event hanlder to each new cell in the row. I’d like to remove this event handler when the row is removed as I believe not doing so would cause the cell object to be leaked. However I can’t find a RemovingDataRow event or similar, does such an event exist?

    I could add code to remove the events everytime a row is explicitly removed but this feels quite a bit harder than just using a event. 

    Cheers,
    Rob 

     

    Imported from legacy forums. Posted by Robert (had 469 views)

    User (Old forums)
    Member
    Post count: 23064

    There will be no memory leak as long as the lifespan of the object containing the callback method is longer than the lifespan of the object exposing the event.  That is, if you subscribe to an event on a cell, and the event handler (the callback) is an instance method of the form on which the grid is located, then when deleting the cell, it will not leak since the object exposing the event (the cell) has a shorter lifespan than the object containing the event handler (the form).

    BTW, do you really need to subscribe to cell events in the AddingDataRow event?  You can use the DataRowTemplate to do this once, when the grid is first initialized.

    e.g. :

    foreach( Cell cell in dataRowTemplate1.Cells )

    {

        cell.ValueChanged +=

    new EventHandler( cell_ValueChanged );

    }

     

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

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