CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 1999
    Location
    MD, USA
    Posts
    34

    key movements in Flexgrid..........

    Am using a flex grid to display data. Also, the user can enter or update data (am doing this using a text box, which sets itself on the selected cell).

    I want to be able to use the arrow keys to move between cells. Whenever the text box is in a cell that cannot be changed, this works fine, but when it goes to any cell where data can be entered or updated, it stops working and gets stuck there. The cursor just moves within the cell at this point.

    Any suggestion ? ? ?


  2. #2
    Join Date
    Nov 1999
    Posts
    4

    Re: key movements in Flexgrid..........

    Well, I'm using the flex grid too but I dont allow the users to update cells directly over the grid. Instead I use a form wich is displayed when the user clicks or press enter over a row of data..

    Hope it helps


  3. #3
    Join Date
    Dec 1999
    Location
    MD, USA
    Posts
    34

    Re: key movements in Flexgrid..........

    Using a pop-up form is a good option. But in my case, I need to let the user see the effects of the updates immediately (user makes prepayments and this changes the total amounts i have in the top row).

    Does your flex grid allow you to use the arrow keys to move from a cell to another?


  4. #4
    Join Date
    Jul 1999
    Location
    Athens, Hellas
    Posts
    769

    Re: key movements in Flexgrid..........

    Set the keypreview property of your form to true and check the keypress event of the form in order to move with arrows... Any further help, ask me here.

    Michael Vlastos
    Automation Engineer
    Company SouthGate Hellas SA
    Development Department
    Athens, Greece

  5. #5
    Join Date
    Dec 1999
    Location
    MD, USA
    Posts
    34

    Re: key movements in Flexgrid..........

    Thanks for the suggestion, but I already have it set to true.
    The key movement works fine until it comes to a cell which can be updated and gets stuck there ! ! !


  6. #6
    Join Date
    Sep 1999
    Location
    Red Wing, MN USA
    Posts
    312

    Re: key movements in Flexgrid..........

    You would need to trap the Navigation Messages within the Textbox on the Grid, then Redirect them to the Grid itself, here's an Example:

    Add a MSFlexGrid and a Textbox to a Form..

    private Sub Form_Activate()
    MSFlexGrid1_Click
    End Sub

    private Sub Form_Load()
    'Make the Minimum Row Height Match the Textbox Height to
    'Make it a snug fit.
    Text1.Height = 28
    With MSFlexGrid1
    .Move 0, 0, ScaleWidth, ScaleHeight
    .FixedRows = 0
    .FixedCols = 0
    .Rows = 3
    .Cols = 5
    .RowHeightMin = Text1.Height
    End With
    End Sub

    private Sub MSFlexGrid1_Click()
    With MSFlexGrid1
    Text1 = .Text
    Text1.Height = .RowHeight(.Row)
    'Position the Control on the Grid
    Text1.Move .Left + .ColPos(.Col) + 50, .Top + .RowPos(.Row) + 50, .ColWidth(.Col)
    'Show the Control
    Text1.Visible = true
    Text1.SetFocus
    End With
    End Sub

    private Sub MSFlexGrid1_RowColChange()
    MSFlexGrid1_Click
    End Sub

    private Sub Text1_Change()
    'Save Contents of the Textbox to the Grid
    MSFlexGrid1.Text = Text1
    End Sub

    private Sub Text1_KeyDown(KeyCode as Integer, Shift as Integer)
    'Dirvert Navigation Keys to the Grid
    Select Case KeyCode
    Case vbKeyUp, vbKeyDown, vbKeyLeft, vbKeyRight
    MSFlexGrid1.SetFocus
    If KeyCode = vbKeyUp then
    SendKeys "{UP}"
    ElseIf KeyCode = vbKeyDown then
    SendKeys "{Down}"
    ElseIf KeyCode = vbKeyLeft then
    SendKeys "{Left}"
    else
    SendKeys "{Right}"
    End If
    End Select
    End Sub




    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]
    Aaron Young
    Senior Programmer Analyst (Red Wing Software)
    Certified AllExperts Expert

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured