本人想要一个:它应该是一个X行Y列的二维表格,X和Y可以根据需要确定,每一个表单元都可以用作文本输入,请问那位高手有这样的控件啊????
补充:用mshflexgrid好像不行,试过了,应为它是只读的,我想让这个程序在运行时,用户能通过键盘对表格里面的数据进行输入和修改,而mshflexgrid不行
补充:用mshflexgrid好像不行,试过了,应为它是只读的,我想让这个程序在运行时,用户能通过键盘对表格里面的数据进行输入和修改,而mshflexgrid不行
http://download.csdn.net/source/293552
请看它所有e开头的属性
'************************************
'* 名称:msgCondition_MouseDown
'* 功能:
'* 作者: zhzhufeng
'* 参数:无
'* 描述:
'************************************
Private Sub msgCondition_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim i, j As Integer
With msgCondition
txtInput.Visible = False
If Button = 1 Then
If .col = 1 Then
txtInput.Width = .CellWidth
txtInput.Left = .Left + .CellLeft
txtInput.Top = .Top + .CellTop
txtInput.Height = .CellHeight
txtInput.Text = .Text
txtInput.SelStart = 0
txtInput.SelLength = Len(txtInput.Text)
txtInput.Visible = True
txtInput.ZOrder
txtInput.SetFocus
.ZOrder 1
End If
End If
End With
End Sub
回车和四个方向键都可以支持
充分利用Msflexgrid提供的各种事件,可以近乎完美地解决数据输入的问题
说实在话,用MSflexgrid编辑数据,代码真的很繁琐Private Sub txtPrice_KeyDown(KeyCode As Integer, Shift As Integer)
Dim Cancel As Boolean
If KeyCode = vbKeyUp Or KeyCode = vbKeyDown Then
Call txtPrice_Validate(Cancel)
If Cancel Then
KeyCode = 0
End If
End If
With grdTrans
Select Case KeyCode
Case vbKeyUp
If .Row > 1 Then
If .Row = .TopRow Then
.TopRow = .Row - 1
End If
.Row = .Row - 1
.SetFocus
Call grdTrans_EnterCell
' .SetFocus
End If
KeyCode = 0
Case vbKeyDown
If .Row < .Rows - 2 Then
If Not .RowIsVisible(.Row + 1) Then
.TopRow = .TopRow + 1
End If
.Row = .Row + 1
.SetFocus
Call grdTrans_EnterCell
End If
KeyCode = 0
Case vbKeyLeft
If txtPrice.SelStart = 0 Then
Call txtPrice_Validate(Cancel)
If Not Cancel Then
.Col = .Col - 1
txtPrice.Visible = False
Call grdTrans_EnterCell
Else
KeyCode = 0
End If
End If
Case vbKeyRight
If txtPrice.SelStart = Len(txtPrice.Text) Then
Call txtPrice_Validate(Cancel)
If Not Cancel Then
.Col = .Col + 1
grdTrans.SetFocus
txtPrice.Visible = False
Call grdTrans_EnterCell
Else
KeyCode = 0
End If
End If
Case vbKeySpace
KeyCode = 0
''' Case vbKeyReturn
''' KeyCode = 0
End Select
End With
End SubPrivate Sub txtPrice_KeyPress(KeyAscii As Integer)
On Error Resume Next If KeyAscii = 13 Then
txtPrice.Text = AutoCalcPrice(txtPrice.Text)
KeyAscii = 0
SendKeys "{END}"
ElseIf KeyAscii = 32 Then
KeyAscii = 0
End If
End Sub