Click to See Complete Forum and Search --> : key movements in Flexgrid..........


Tina
January 6th, 2000, 03:48 PM
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 ? ? ?

Javier Noriega
January 6th, 2000, 06:25 PM
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

Tina
January 6th, 2000, 08:22 PM
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?

Dr_Michael
January 7th, 2000, 08:13 AM
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

Tina
January 7th, 2000, 08:31 AM
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 ! ! !

Aaron Young
January 7th, 2000, 03:20 PM
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
ajyoung@pressenter.com
aarony@redwingsoftware.com