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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

After removing a dynamic splitter, my events no longer fire. How do I fix this?

Platform: WinForms |
Control: TabBarSplitterControl |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014

 

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

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon 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.Close Icon