Results 1 to 9 of 9

Thread: RESOLVED -> Editing MSHFlexgrid

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2001
    Posts
    1,384

    RESOLVED -> Editing MSHFlexgrid

    Hi all,

    I'm developing an application that has an editable MSHFlexgrid - using a textbox to make the editions. The form has an MSHFlexgrid (grd) and an invisible textbox (txtbox). The code, in it's simplist form is as follows.
    VB Code:
    1. Private Sub Grd_KeyPress(KeyAscii As Integer)
    2.    
    3.     CallEdit KeyAscii, txtBox
    4.    
    5. End Sub
    6.  
    7. Private Sub CallEdit(txtKey As Integer, txtB As Control)
    8.  
    9.     Select Case txtKey
    10.         Case 0 To 32
    11.             With txtB
    12.                 .Text = Grd.Text
    13.                 .SelStart = Len(.Text)
    14.             End With
    15.         Case Else
    16.             With txtB
    17.                 .Text = Chr(txtKey)
    18.                 .SelStart = 1
    19.             End With
    20.     End Select
    21.  
    22.     With Grd
    23.         txtB.Move .Left + .CellLeft, _
    24.             .Top + .CellTop, _
    25.             .CellWidth - 8
    26.     End With
    27.  
    28.     txtB.Visible = True
    29.     txtB.SetFocus
    30.  
    31. End Sub
    32.  
    33. Private Sub Grd_LeaveCell()
    34.  
    35.     If txtBox.Visible = False Then Exit Sub
    36.  
    37.     SaveTxt txtBox
    38.  
    39.     Grd.Col = Grd.Col + 1
    40.     Grd.SetFocus
    41.  
    42. End Sub
    43.  
    44. Private Sub Grd_GotFocus()
    45.    
    46.     If txtBox.Visible = False Then Exit Sub
    47.  
    48.     SaveTxt txtBox
    49.     Grd.Col = Grd.Col + 1
    50.    
    51. End Sub
    52.  
    53. Private Sub SaveTxt(txtB As Control)
    54.  
    55.     Grd.Text = txtB.Text
    56.     txtB = ""
    57.     txtB.Visible = False
    58.  
    59. End Sub
    60.  
    61. Private Sub txtBox_KeyDown(KeyCode As Integer, Shift As Integer)
    62.  
    63.     If KeyCode = 13 Then        'Return
    64.         Grd.SetFocus
    65.     ElseIf KeyCode = 27 Then    'Escape
    66.         txtBox = ""
    67.         txtBox.Visible = False
    68.         Grd.SetFocus
    69.     End If
    70.  
    71. End Sub
    72.  
    73. Private Sub txtBox_LostFocus()
    74.  
    75.     Grd.SetFocus
    76.  
    77. End Sub
    So when the user starts typing in a cell the text box appears in that cell (seamlessly), when the user tabs or returns on the textbox, the text is entered into the grid. To the user it should looks like they are typing directly in the grid. I've done this loads of times before for other applications without a hassle. But the problem I'm having now on one PC is when typing in the grid, the textbox doesn't line up with the cell to be edited. It seems to be over more to the right and below the cell. I've been testing this application on a few PCs and there's no problem with any of the others, only this one. Can anyone help?
    Last edited by mel_flynn; Feb 13th, 2006 at 04:52 AM.
    Mel

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