We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

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

Article ID: Published Date: Last Revised Date: Platform: Control:
494 04/30/2011 07/10/2014 Windows Forms TabBarSplitterControl
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.