首先應該建立一個combo1的comboBox控件,作為下拉框的最終實現工具。
Private Sub Combo1_Click()
MSFlexGrid1.Row = MSFlexGrid1.RowSel
MSFlexGrid1.Col = 2
MSFlexGrid1.Text = Combo1.Text
End Sub
'Private Sub Combo1_LostFocus()
'Combo1.Text = MSFlexGrid1.Text
'End Sub
Private Sub Form_Load()
Combo1.Visible = False
Combo1.AddItem "aaa"
Combo1.AddItem "bbb"
Combo1.AddItem "ccc"
MSFlexGrid1.Cols = 10
MSFlexGrid1.Rows = 10
End Sub
Private Sub MSFlexGrid1_EnterCell()
If MSFlexGrid1.Col = 2 Then
MSFlexGrid1.CellBackColor = vbWhite
MSFlexGrid1.CellForeColor = vbBlue
Combo1.Move MSFlexGrid1.Left + MSFlexGrid1.CellLeft, MSFlexGrid1.Top + MSFlexGrid1.CellTop, MSFlexGrid1.CellWidth
Combo1.Visible = True
'Combo1.Text = MSFlexGrid1.Text
Else
Exit Sub
End If
' Combo1.SelStart = 0
' Combo1.SelLength = Len(Combo1.Text)
End Sub
Private Sub MSFlexGrid1_LeaveCell()
'If MSFlexGrid1.Col = 2 Then
MSFlexGrid1.CellBackColor = vbWhite
MSFlexGrid1.CellForeColor = vbBlue
'Combo1.Move MSFlexGrid1.Left + MSFlexGrid1.CellLeft, MSFlexGrid1.Top + MSFlexGrid1.CellTop, MSFlexGrid1.CellWidth
'MSFlexGrid1.Text = Combo1.Text
' Else
'Exit Sub
'End If
End Sub
'Private Sub Combo1_Change()
'MSFlexGrid1.Row = MSFlexGrid1.RowSel
'MSFlexGrid1.Col = 2
'MSFlexGrid1.Text = Combo1.Text
'End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = True
Combo1.Visible = False
End Sub