|
-
Apr 25th, 2002, 09:21 AM
#1
Ever work with MS ****... er... flex grid??
I'm working with a flex grid, which I've "connected" to a database, using ADO. When the user clicks on the flexgrid, I bring a borderless textbox there, so the user can type something, and I update the database in the textbox validate event.
That sucks somewhat. I wanted to detect the escape, enter and tab keys, so I moved the db-update code to the textbox keydown event. If the user pressed escape, I'd just remove the textbox. But the keydown event won't detect the TAB and ENTER keys. If it's a standalone textbox, it'll detect it fine. But when it's over the flexgrid, it won't detect enter and tab.
This ever happen to you?
What do you do for the "update"?
Tell me what I'm doing wrong.
Anything else you'd like to add?
TIA.
-
Apr 25th, 2002, 09:25 AM
#2
Why don't you just edit it directly, rather than using a textbox?
-
Apr 25th, 2002, 09:27 AM
#3
You can't edit a flex grid directly, Hack. Try it. 
gee... hope i'm not mistaken....
-
Apr 25th, 2002, 09:29 AM
#4
Sure you can
VB Code:
Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)
With MSFlexGrid1
Select Case KeyAscii
Case 8: 'IF KEY IS BACKSPACE THEN
If .Text <> "" Then .Text = _
Left$(.Text, (Len(.Text) - 1))
Case 13: 'IF KEY IS ENTER THEN
Select Case .Col
Case Is < (.Cols - 1):
SendKeys "{right}"
Case (.Cols - 1):
If (.Row + 1) = .Rows Then
.Rows = .Rows + 1
End If
SendKeys "{home}" + "{down}"
End Select
Case Else
.Text = .Text + Chr$(KeyAscii)
'write your own keyascii Validations under
'commented lines
Select Case .Col
Case 0, 1, 2:
'if (your condition(s)) then
'accept only charectors
'Else
' keyascii=0
'End If
Case Else:
End Select
End Select
End With
End Sub
-
Apr 25th, 2002, 09:32 AM
#5
//stunned 
Thanks. I'll try this and get back.
-
Apr 25th, 2002, 10:05 AM
#6
that's a nice trick hack, but it doesn't work for Esc... what I do is the textbox method, and update when lostfocus occurs - with a boolean which I set if esc is pressed (which then means update is ignored).
Also you could set it to only update if enter is pressed, eg:
VB Code:
Private Sub txtEdit_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
MSFlexGrid1.Text = txtEdit.Text
txtEdit.Visible=False
ElseIf KeyAscii = 27 Then
txtEdit.Visible=False
End If
End Sub
-
Apr 25th, 2002, 10:09 AM
#7
Oh dear. I just checked that. Wonderful square boxes there. 
And I just edited all my code to fit that. Now you know why i call it the **** GRID!!! 
SiGeek: How is the lostfocus method fired? when the user clicks elsewhere on the form? Or a simple tab?
Can you give me a couple more details?
-
Apr 25th, 2002, 10:21 AM
#8
-
Apr 25th, 2002, 11:32 AM
#9
Hmm... I worked on it. I came back to this post. read it, re-read it and double re-read it.
now I'm back where I started. Isn't that just the sweetest thing?
[FRUSTRATION]
AAAAAAAAAAAAAAAAAAAAAAAAAAARRRRRGGGHHHHH!!!
[/FRUSTRATION]
Is there NO way to capture a TAB inside a Textbox? *sniffle*
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|