Results 1 to 9 of 9

Thread: Ever work with MS ****... er... flex grid??

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Why don't you just edit it directly, rather than using a textbox?

  3. #3

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    You can't edit a flex grid directly, Hack. Try it.



    gee... hope i'm not mistaken....

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Sure you can
    VB Code:
    1. Private Sub MSFlexGrid1_KeyPress(KeyAscii As Integer)
    2.  
    3.     With MSFlexGrid1
    4.         Select Case KeyAscii
    5.                
    6.             Case 8: 'IF KEY IS BACKSPACE THEN
    7.                 If .Text <> "" Then .Text = _
    8.                  Left$(.Text, (Len(.Text) - 1))
    9.             Case 13: 'IF KEY IS ENTER THEN
    10.                 Select Case .Col
    11.                     Case Is < (.Cols - 1):
    12.                         SendKeys "{right}"
    13.                     Case (.Cols - 1):
    14.                         If (.Row + 1) = .Rows Then
    15.                             .Rows = .Rows + 1
    16.                         End If
    17.                         SendKeys "{home}" + "{down}"
    18.                 End Select
    19.             Case Else
    20.                 .Text = .Text + Chr$(KeyAscii)
    21.                 'write your own keyascii Validations under
    22.                        'commented lines
    23.                 Select Case .Col
    24.                     Case 0, 1, 2:
    25.                         'if (your condition(s)) then
    26.                             'accept only charectors
    27.                         'Else
    28.                         '   keyascii=0
    29.                         'End If
    30.                     Case Else:
    31.                 End Select
    32.         End Select
    33.     End With
    34.  
    35. End Sub

  5. #5

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    //stunned

    Thanks. I'll try this and get back.

  6. #6
    Si_the_geek
    Guest
    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:
    1. Private Sub txtEdit_KeyPress(KeyAscii As Integer)
    2.  
    3.   If KeyAscii = 13 Then
    4.     MSFlexGrid1.Text = txtEdit.Text
    5.     txtEdit.Visible=False
    6.   ElseIf KeyAscii = 27 Then
    7.     txtEdit.Visible=False
    8.   End If
    9.  
    10. End Sub

  7. #7

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    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?

  8. #8

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Originally posted by Si_the_geek
    I thought a frog like you would know that!!

    it is called whenever the control looses the focus, whether the mouse is clicked elsewhere or tab is pressed.


    I reckon your best bet would be the code I posted above, as users will often click out of a text box to cancel it (your choice tho!)
    I know it gets fired in when tab is pressed. NOT what I want within the flex grid... i wanted that if the user presses tab, it does NOT lose focus, rather it goes to the next cell... DARN MICROSOFT DARN ****GRID. Aaargh... I feel like wokawidget today.....

    AAAAAAAAAAARRRRRRRRRGGGGHhHH....


    oh, thanks SIGeek. , ty, hack.

  9. #9

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    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
  •  



Click Here to Expand Forum to Full Width