首先应该建立一个combo1的comboBox控件,作为下拉框的最终实现工具。
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/bianchengyuyan/)
Private Sub Combo1_Click()(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/bianchengyuyan/)
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