FlexGrid for WinForms
Step 3 of 5: Add Custom Mouse and Keyboard Handling
Show AllShow All
Hide AllHide All

The C1FlexGrid provides the expanding and collapsing for you, but you may extend and customize its behavior. Every time a branch is expanded or collapsed, the control fires the BeforeCollapse and AfterCollapse events so you may take actions in response to that. Furthermore, you may use the Collapsed property to get and set the collapsed state of each branch in code.

In this tutorial, we will trap the DoubleClick and KeyPress events to expand and collapse nodes when the user double clicks or presses the ENTER key. Add the following DoubleClick and KeyPress events to the form:

To write code in Visual Basic

To write code in C#

Run the program and observe the following:

The event handlers check whether the user double-clicked the first column or hit the ENTER key, then call the ToggleNodeState routine. ToggleNodeState checks whether the current row is a node row, and toggles the value of the Collapsed property if it is.

See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Product Support Forum |  Documentation Feedback