Results 1 to 10 of 10

Thread: MSFlexgrid

  1. #1

    Thread Starter
    Fanatic Member Kzin's Avatar
    Join Date
    Dec 2000
    Posts
    611

    MSFlexgrid

    Dumb question but I can't quite figure it out. How do I set things so that when I click on a cell in MSFlexgrid I can

    1) edit it
    2) detect changes
    Looking for a friendly intelligent chat forum? Visit the white-hart.net

  2. #2
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    Edit it?

    Simple version...

    Me.text1.text = me.msflexgrid1.textmatrix(me.msflexgrid1.rowsel,me.msflexgrid1.colsel)
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  3. #3
    donW
    Guest
    if you want to edit a cell (like it was atextbox) then search vbworld for
    'flexgrid' you will find the code to pulldown a textbox over a cell

  4. #4

    Thread Starter
    Fanatic Member Kzin's Avatar
    Join Date
    Dec 2000
    Posts
    611
    I just want to enter numbers and text in the cells just as I would with an excel sheet and trigger an event so that can save them as I go. I searched before I posted and couldn't find anything suitable.
    Looking for a friendly intelligent chat forum? Visit the white-hart.net

  5. #5
    donW
    Guest
    yes i found code
    search this forum for 'msflexgrid'

    it gives you the reference in MSDN
    both code examples are poor, and dont do what I want...
    I am going to troll the net for a better control.. will reply later if
    i find anything

  6. #6

    Thread Starter
    Fanatic Member Kzin's Avatar
    Join Date
    Dec 2000
    Posts
    611
    Ok I found this http://support.microsoft.com/support.../Q241/3/55.ASP on MSDN but it seems very cumbersome. Anyone got any idea how to trigger an event just by clicking on a cell?
    Looking for a friendly intelligent chat forum? Visit the white-hart.net

  7. #7

    Thread Starter
    Fanatic Member Kzin's Avatar
    Join Date
    Dec 2000
    Posts
    611

    One line answer

    This does it

    MSFlexGrid1.Text = InputBox("Enter new value", ,MSFlexGrid1.Text)
    Looking for a friendly intelligent chat forum? Visit the white-hart.net

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

  9. #9

    Thread Starter
    Fanatic Member Kzin's Avatar
    Join Date
    Dec 2000
    Posts
    611
    It works- very clever - actually cleverer and more to the point than the MSDN example!
    Looking for a friendly intelligent chat forum? Visit the white-hart.net

  10. #10

    Thread Starter
    Fanatic Member Kzin's Avatar
    Join Date
    Dec 2000
    Posts
    611
    Thanks Hack
    Looking for a friendly intelligent chat forum? Visit the white-hart.net

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