Text1.BorderStyle = 0
Text1.Visible = False
End Sub
Private Sub MSFlexGrid1_Click()
With MSFlexGrid1
'If .Col <> 2 Then Exit Sub '只能编辑第二列
Text1.Visible = True
Text1.Move .CellLeft + .Left, .CellTop + .Top, .CellWidth, .CellHeight
Text1.Text = .Text
Text1.SetFocus
End With
'MsgBox MSFlexGrid1.TextMatrix(10, 2)
End Sub
Private Sub MSFlexGrid1_Scroll()
With MSFlexGrid1
If .ColIsVisible(.Col) And .RowIsVisible(.Row) Then
Text1.Visible = True
Text1.Move .CellLeft + .Left, .CellTop + .Top, .CellWidth, .CellHeight
Text1.SetFocus
Else
Text1.Visible = False
End If
End With
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
'在此根据主键更新数据库
cn.Execute "UPDATE TABLENAME SET FIELD = '" & Text1.Text & "' WHERE ID = ...."
MSFlexGrid1.Text = Text1.Text
Text1.Visible = False
MSFlexGrid1.SetFocus
End If
End Sub