MsFlexgrid实现输入数据的有关问题
MsFlexgrid实现输入数据的问题
关于如何在MsFlexgrid中输入数据,我在网站上看到了这样的实现代码
我新建了一个名字为gridtext的textbox框
Private Sub FormLoad()
gridtext.Move -10000, -10000, 1, 1
End Sub
Private Sub MSFlexGrid1EnterCell()
MSFlexGrid1.CellBackColor = vbYellow
MSFlexGrid1.CellForeColor = vbRed
gridtext.Text = MSFlexGrid1.Text
gridtext.SelStart = 0
gridtext.SelLength = Len(gridtext.Text)
End Sub
Private Sub MSFlexGrid1LeaveCell()
MSFlexGrid1.CellBackColor = vbWhite
MSFlexGrid1.CellForeColor = vbBlue
End Sub
Private Sub MSFlexGrid1MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
MSFlexGrid1.CellBackColor = vbYellow
MSFlexGrid1.CellForeColor = vbRed
gridtext.SetFocus
End Sub
Private Sub gridtextChange()
MSFlexGrid1.Text = gridtext.Text
End Sub
Private Sub gridtextKeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyLeft, vbKeyRight, vbKeyUp, vbKeyDown
KeyCode = 0
End Select
End Sub
确实可以实现在MsFlexgrid中的数据输入。不过我还有几个问题,希望各位高手能赐教
1.如何在输入的时候看到像输入textbox那样的光标?
2.能不能实现用tab键或者上下键来切换要输入的单元格?像excel那样。
3.能不能解释以下gridtext_keydown()过程是什么意思?
VisualBasic程序开发环境 程序开发 VisualBasic
Answers
呵呵,我做过类似的开发,当时做了一个MSHFlexGrid控件用来显示和编辑一张表,而且编辑的时候使用了TextBox,CheckBox,ComboBox等控件,处理起来比较烦琐,但是不难。大致实现方法:
Private Sub hflexSpxx_Click()
With hflexSpxx
c = .Col: r = .Row
Select Case c
Case 6 '显示品牌选择框
combPp.Left = .Left + .ColPos(c) + 150
combPp.Top = .Top + .RowPos(r) + 135
combPp.Width = .ColWidth(c)
EscString = .Text
combPp.Text = .Text
combPp.Visible = True
combPp.SetFocus
'MsgBox "品牌框"
Case 9 '显示商品类别选择框
combSplb.Left = .Left + .ColPos(c) + 150
combSplb.Top = .Top + .RowPos(r) + 135
combSplb.Width = .ColWidth(c)
EscString = .Text
combSplb.Text = .Text