'我以vsFlexGrid表格控件和普通的按钮控件为例给你举个例子:
'表格控件名: Mygrid
'按钮控件名: Command1
'注意事项:在窗体放控件的时候要将按钮控件置前!不然看不到效果的哦!
'---定义表格
Private Sub Form_Load()
Command1.Visible = False
With Mygrid
.Cols = 3
.Rows = 3
.TextMatrix(0, 0) = "学号"
.TextMatrix(0, 1) = "性别"
.TextMatrix(0, 2) = "年龄"
.TextMatrix(1, 0) = "0001"
.TextMatrix(1, 1) = "男"
.TextMatrix(1, 2) = "20"
.TextMatrix(2, 0) = "0002"
.TextMatrix(2, 1) = "女"
.TextMatrix(2, 2) = "22"
End With
End Sub
Private Sub Mygrid_Click()
With Mygrid
If .Rows = 1 Or .Row = 0 Then Exit Sub
Select Case .Col
Case 0 '如果用户点击第一列才处理
Command1.Top = .Top + .CellTop + 20
Command1.Left = .Left + .CellLeft + 20
Command1.Width = .CellWidth - 10
Command1.Height = .CellHeight - 10
Command1.Visible = True
Command1.Caption = "你想要的按钮名称"
Command1.SetFocus
Case Else
Command1.Visible = False
End Select
End With
end Sub
Private Sub Command1_Click()
'编写你要处理的程序
MsgBox ("学号:" & Mygrid.TextMatrix(Mygrid.Row, 0))
End Sub
----------------------------------------------------------
以上是我的个人做法,有问题可以和我联系!大家互相帮助嘛!
呵呵.......
QQ:7422224,找我时注明VB