我设了datagrid的button属性,可以显示一个下拉按钮,就像combobox的下接按钮一样。
但是我点了却没有东西,我不知道怎么写代码?我看书上,datagrid有一个buttonclick事件,但我不知道怎么写代码。
我想实现的功能是,我一点button,就会出来一个下拉菜单,选中其中的项,内容就会填到表格中,就像combobox一样。
请各位帮帮忙。
但是我点了却没有东西,我不知道怎么写代码?我看书上,datagrid有一个buttonclick事件,但我不知道怎么写代码。
我想实现的功能是,我一点button,就会出来一个下拉菜单,选中其中的项,内容就会填到表格中,就像combobox一样。
请各位帮帮忙。
Dim intCol As IntegerPrivate Sub Combo1_Click()
Combo1.Visible = False
DataGrid1.Row = intRow
DataGrid1.Col = intCol
DataGrid1.Text = Combo1.Text
End SubPrivate Sub DataGrid1_ButtonClick(ByVal ColIndex As Integer)
With DataGrid1
intRow = .Row
intCol = ColIndex
Combo1.Left = .Left + .Columns(ColIndex).Left
Combo1.Top = .Top + .RowHeight * (.Row + 1)
Combo1.Width = .Columns(ColIndex).Width
Combo1.Visible = True
End With
End SubPrivate Sub Form_Load()
Dim i As Integer
For i = 1 To 10
Combo1.AddItem i
Next i
Combo1.Visible = False
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
List1.Visible = False
End Sub
Private Sub list1_Click()
List1.Visible = False
DataGrid1.Text = List1.Text
End SubPrivate Sub DataGrid1_ButtonClick(ByVal ColIndex As Integer)
With DataGrid1
List1.Left = .Left + .Columns(ColIndex).Left
List1.Top = .Top + .RowHeight * (.Row + 2)
List1.Width = .Columns(ColIndex).Width
List1.Visible = True
End With
End SubPrivate Sub Form_Load()
With List1
.Appearance = 0
.Height = 450
.AddItem "真"
.AddItem "假"
.Visible = False
End With
End Sub