ComponentOne VSFlexGrid 8.0
Step 7: Custom Mouse and Keyboard Handling

To add custom mouse and keyboard handling similar to those implemented in the Visual Basic version of the Outline demo, we need to handle the DblClick and KeyPress events.

Adding the event handlers is easy: click CTRL-W to invoke the Wizard, select the VSFLEXGRID1 object on the Object Ids list, then select each event and click the Add Function button. When you are done, click the Edit Code button and type the following code:

Example Title
Copy Code
#define flexOutlineExpanded  0

  #define flexOutlineSubtotals 1

  #define flexOutlineCollapsed 2


  void COutlineCDlg::OnDblClickVsflexgrid1()

  {

    // double clicking on a row expands or collapses it 

    long r = m_fg.GetRow();

    if (m_fg.GetIsCollapsed(r) == flexOutlineCollapsed)

        m_fg.SetIsCollapsed(r, flexOutlineExpanded);

    else

        m_fg.SetIsCollapsed(r, flexOutlineCollapsed);

  }

  void COutlineCDlg::OnKeyPressVsflexgrid1(short FAR* KeyAscii)

  {

    if (*KeyAscii == VK_RETURN) {

      OnDblClickVsflexgrid1();

      *KeyAscii = 0;

    }

  }

Again, the code is a line-by-line translation of the Visual Basic Outline example.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback