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:
Private Sub Grd_KeyPress(KeyAscii As Integer)
CallEdit KeyAscii, txtBox
End Sub
Private Sub CallEdit(txtKey As Integer, txtB As Control)
Select Case txtKey
Case 0 To 32
With txtB
.Text = Grd.Text
.SelStart = Len(.Text)
End With
Case Else
With txtB
.Text = Chr(txtKey)
.SelStart = 1
End With
End Select
With Grd
txtB.Move .Left + .CellLeft, _
.Top + .CellTop, _
.CellWidth - 8
End With
txtB.Visible = True
txtB.SetFocus
End Sub
Private Sub Grd_LeaveCell()
If txtBox.Visible = False Then Exit Sub
SaveTxt txtBox
Grd.Col = Grd.Col + 1
Grd.SetFocus
End Sub
Private Sub Grd_GotFocus()
If txtBox.Visible = False Then Exit Sub
SaveTxt txtBox
Grd.Col = Grd.Col + 1
End Sub
Private Sub SaveTxt(txtB As Control)
Grd.Text = txtB.Text
txtB = ""
txtB.Visible = False
End Sub
Private Sub txtBox_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then 'Return
Grd.SetFocus
ElseIf KeyCode = 27 Then 'Escape
txtBox = ""
txtBox.Visible = False
Grd.SetFocus
End If
End Sub
Private Sub txtBox_LostFocus()
Grd.SetFocus
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?