要在VB中的MSFLEXGRID的某一列的所有行上加一个按钮,默认不显示,如何加?求代码!!
要在VB中的MSFLEXGRID的某一列的所有行上加一个按钮,默认不显示,如何加?求代码!!
MSHFlexgrid1.Row=intRow
MSHFlexgrid1.Col=intCol
Command1.Left=MSHFlexgrid1.CellLeft
Command1.top=MSHFlexgrid1.CellTop
Command1.Width=MSHFlexGrid1.CellWidth
Command1.Width=MSHFlexGrid1.CellHeight
你太快了
Option Explicit
Private WithEvents btnP As CommandButton
Private Sub Form_Load()
Dim intRow As Integer
With MSHFlexGrid1
.Rows = 100
.Cols = 5
For intRow = 1 To 99
.Row = intRow
.Col = 3 '¹Ì¶¨ÔÚµÚÈýÁÐ
Set btnP = Controls.Add("VB.CommandButton", "btn" & CStr(intRow))
btnP.Move .Left + .CellLeft, .Top + .CellTop, .CellWidth, .CellHeight
btnP.Visible = True
btnP.ZOrder 0
Next intRow
End With
End Sub
请教一下,按钮事件如何触发? 要触发事件,这样修改一下:
'***********************************************************************************************
'方法说明:请手动在窗体中添加一个按钮控件:btnP,并将其Index属性设置为:0
'
'***********************************************************************************************
Option Explicit
Private Sub btnP_Click(Index As Integer)
Debug.Print Index
End Sub
Private Sub Form_Load()
Dim intRow As Integer
With MSHFlexGrid1
.Rows = 100
.Cols = 5
For intRow = 1 To 99
.Row = intRow
.Col = 3 '设置要生成控件的列
Load btnP(intRow) '载入按钮控件
btnP(intRow).Move .Left + .CellLeft, .Top + .CellTop, .CellWidth, .CellHeight
btnP(intRow).Visible = True
btnP(intRow).ZOrder 0
Next intRow
End With
End Sub
这说明我很无聊.....
我想知道的是,用这个方式 Set btnP = Controls.Add("VB.CommandButton", "btn" & CStr(intRow)) 加载的控件的事件怎么触发,谢谢。
补充:VB , 基础类