Flex Grid Question


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Flex Grid Question

  1. #1
    Mike Gorgone Guest

    Flex Grid Question


    Does anyone know how to trap the arrow keys when using the flex grid control.
    The keydown and keyup events are not firing when I press the up and down
    arrows. I would like to use the arrows for changing data values so I need
    to keep the arrow keys from changing the selected cell. Any help is appreciated.

    Thanks,

    Mike

  2. #2
    mark erickson Guest

    Re: Flex Grid Question


    Hi Mike!

    You can "trap" the up/down arrows in the keydownEdit event, but you can't
    set the flexgrid.textmatrix property there (flexgrid will overwrite your
    change). I suggest creating a variable (lastArrow) that will save which
    arrowkey that the user pushed.

    Then change the arrowkey into vbkeyEnter which forces the edit to end and
    also keeps the focus from leaving the current cell.

    Finally, use flexgrid.afteredit to check lastArrow to determine which arrowkey
    the user pushed, if any. You can change the flexgrid.textmatrix value accordingly.

    Like so...


    <in general declarations> dim lastArrow as integer


    Private Sub VSFlexGrid1_KeyDownEdit(ByVal Row As Long, ByVal Col As Long,
    KeyCode As Integer, ByVal Shift As Integer)
    Select Case KeyCode
    Case vbKeyUp, vbKeyDown
    lastArrow = KeyCode
    KeyCode = 13
    End Select
    End Sub


    Private Sub VSFlexGrid1_AfterEdit(ByVal Row As Long, ByVal Col As Long)

    Select Case lastArrow
    Case vbKeyUp
    'User typed uparrow: change VSFlexGrid1.TextMatrix accordingly
    VSFlexGrid1.EditCell
    lastArrow=0
    Case vbKeyDown
    'User typed down: change VSFlexGrid1.TextMatrix accordingly
    VSFlexGrid1.EditCell
    lastArrow=0
    End Select

    End Sub



    "Mike Gorgone" <mgorgone@technium.com> wrote:
    >
    >Does anyone know how to trap the arrow keys when using the flex grid control.
    >The keydown and keyup events are not firing when I press the up and down
    >arrows. I would like to use the arrows for changing data values so I need
    >to keep the arrow keys from changing the selected cell. Any help is appreciated.
    >
    >Thanks,
    >
    >Mike



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center