After removing a dynamic splitter, my events no longer fire. How do I fix this?
If you are handling events for grids in dynamic splitters (like the TabBarSplittlerControl or the GridRecordNavigationControl) then, you have to dynamically subscribe (in PaneCreated) and unsubcribe (in PaneClosing) to the events.
Take a look at some of the samples in the Syncfusion\Essential Suite\Grid\Samples\CellTypes folder to see how they subscribe and unsubscribe to the grid events. The reason you have to do this is that when panes are created and closed, new grid objects are created and destroyed. So, just subscribing to events once for a particular grid in a Form_Load is not sufficient.
C#
private void splitterControl1_PaneClosing(object sender, SplitterPaneEventArgs e)
{
GridControl grid = (GridControl) e.Control;
grid.CurrentCellMoved -= new GridCurrentCellMovedEventHandler(this.grid_CurrentCellMoved); grid.SelectionChanged -= new GridSelectionChangedEventHandler(grid_SelectionChanged);
}
private void splitterControl1_PaneCreated(object sender, SplitterPaneEventArgs e)
{
GridControl grid = (GridControl) e.Control;
grid.CurrentCellMoved += new GridCurrentCellMovedEventHandler(this.grid_CurrentCellMoved);
grid.SelectionChanged += new GridSelectionChangedEventHandler(grid_SelectionChanged);
}
VB
Private Sub splitterControl1_PaneClosing(ByVal sender As Object, ByVal e As SplitterPaneEventArgs) Handles splitterControl1.PaneClosing
Dim grid As GridControl = CType(e.Control, GridControl)
RemoveHandler grid.CurrentCellMoved, AddressOf Me.grid_CurrentCellMoved
RemoveHandler grid.SelectionChanged, AddressOf grid_SelectionChanged
End Sub
Private Sub splitterControl1_PaneCreated(ByVal sender As Object, ByVal e As SplitterPaneEventArgs) Handles splitterControl1.PaneCreated
Dim grid As GridControl = CType(e.Control, GridControl)
AddHandler grid.CurrentCellMoved, AddressOf Me.grid_CurrentCellMoved
AddHandler grid.SelectionChanged, AddressOf grid_SelectionChanged
End Sub
Here ia a sample that illustrates this:
http://help.syncfusion.com/support/samples/kb/Grid.Windows/SplitterGridEvents/SplitterGridEvents.zip