Public Sub MGridKeyPress(nKey As Integer, nLeft As Integer, nTop As Integer, MGrid As MSFlexGrid, TxtEdit As TextBox, Optional BCheck As Boolean = False) '本函數在 MSFlexGrid 控件中按鍵時,產生動作的處理 Dim ir, ic As Integer If BCheck = True And MGrid.Row > 0 Then 'BCheck 是檢查數據中是否可為 NULL ir = MGrid.Row - 1 For ic = 1 To MGrid.Cols - 1 If MGrid.TextMatrix(ir, ic) = "" Then MsgBox "上一行還有些數據未填寫", 48, "錄入提示" Exit Sub End If Next End If Select Case nKey Case 0 To 32 TxtEdit = Trim(MGrid) TxtEdit.SelStart = 1000 Case Else TxtEdit = Chr(nKey) TxtEdit.SelStart = 1 End Select TxtEdit.Move MGrid.CellLeft + nLeft, MGrid.CellTop + nTop, MGrid.CellWidth, MGrid.CellHeight TxtEdit.Visible = True TxtEdit.SetFocus End Sub
Private Sub MGrid_LeaveCell() if TxtEdit.Visible=False then exit sub MGrid=TxtEdit.text TxtEdit.visible=false End Sub
Private Sub MGrid_KeyPress(KeyAscii As Integer) ....即按住MsFlexGrid控件時顯示的坐標 MGridKeyPress KeyAscii,左邊數, 上邊數, MGrid, TxtEdit, False .... End Sub
使textbox 不可见
thanks
'本函數在 MSFlexGrid 控件中按鍵時,產生動作的處理
Dim ir, ic As Integer
If BCheck = True And MGrid.Row > 0 Then 'BCheck 是檢查數據中是否可為 NULL
ir = MGrid.Row - 1
For ic = 1 To MGrid.Cols - 1
If MGrid.TextMatrix(ir, ic) = "" Then
MsgBox "上一行還有些數據未填寫", 48, "錄入提示"
Exit Sub
End If
Next
End If
Select Case nKey
Case 0 To 32
TxtEdit = Trim(MGrid)
TxtEdit.SelStart = 1000
Case Else
TxtEdit = Chr(nKey)
TxtEdit.SelStart = 1
End Select
TxtEdit.Move MGrid.CellLeft + nLeft, MGrid.CellTop + nTop, MGrid.CellWidth, MGrid.CellHeight
TxtEdit.Visible = True
TxtEdit.SetFocus
End Sub
if TxtEdit.Visible=False then exit sub
MGrid=TxtEdit.text
TxtEdit.visible=false
End Sub
....即按住MsFlexGrid控件時顯示的坐標
MGridKeyPress KeyAscii,左邊數, 上邊數, MGrid, TxtEdit, False
....
End Sub
如果需要代码与我联系
Oicq:31372306