用 MsHFlexgrid 控件和 command控件组合完成功能

'我以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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值