MSFlexGrid+ Combo+Text 想在实现在MSFlexGrid里,敲了回车就进输入单元格进行编程,不行?
我的代码如下。请指点。。。。Private Sub MSFlexGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 13
If MSFlexGrid1.Col = 1 And MSFlexGrid1.Row <> 0 Then ' Position and size the ListBox, then show it.
If Combo3.Visible = True Then
Combo3.Visible = False
MSFlexGrid1.CellBackColor = &H80000005 'white
End If
Combo3.Width = MSFlexGrid1.CellWidth
' Combo2.Height = MSFlexGrid1.CellHeight
Combo3.Left = MSFlexGrid1.CellLeft + MSFlexGrid1.Left
Combo3.Top = MSFlexGrid1.CellTop + MSFlexGrid1.Top
Combo3.Text = MSFlexGrid1.Text
Combo3.Visible = True
Else
If MSFlexGrid1.Col <> 2 And MSFlexGrid1.Col <> 9 And MSFlexGrid1.Col <> 10 And MSFlexGrid1.Col <> 11 And MSFlexGrid1.Row <> 0 Then
If Text2.Visible = True Then
Text2.Visible = False
MSFlexGrid1.CellBackColor = &H80000005 'white
End If
Text2.Left = MSFlexGrid1.CellLeft + MSFlexGrid1.Left
Text2.Top = MSFlexGrid1.CellTop + MSFlexGrid1.Top
Text2.Width = MSFlexGrid1.CellWidth
Text2.Text = MSFlexGrid1.Text
Text2.Height = MSFlexGrid1.CellHeight
Text2.SelStart = 0
Text2.SelLength = Len(Text2.Text)
Text2.Visible = True
Text2.SetFocus
End If
End If
Case 46 '<Del>, clear cell
MSFlexGrid1.Tag = MSFlexGrid1 'assign to temp storage
MSFlexGrid1 = ""
End Select
End Sub