打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
VB MSHFLEXGRID MSHFLEXGRID 绑定 CHECKBOX

Private Sub MSHFlexGrid1_Click()
If MSHFlexGrid1.Col = 0 Then MSHFlexGrid1.Text = Chr(124 - Asc(MSHFlexGrid1.Text))
End Sub

Private Sub Form_Load()
Dim i As Long
With MSHFlexGrid1
.FixedCols = 0
.Cols = 4
.TextArray(0) = "Flag"
.TextArray(1) = "i"
.TextArray(2) = "i^2"
.TextArray(3) = "i^3"
For i = 1 To 50
.AddItem vbTab & i & vbTab & i ^ 2 & vbTab & i ^ 3
Next
.RemoveItem 1

For i = 1 To 50
.Row = i
.Col = 0
.CellFontName = "Wingdings 2"
.Text = Chr(IIf(i Mod 2 = 0, 82, 42))
Next
End With

End Sub
 

Another method:

Option Explicit

Dim strChecked As String

Private Sub Form_Load()
Dim i As Variant, ms_rows As Integer
    ' Start building the Grid

    ms_rows = 20 ' This is the number of rows to print out
    With MSFlexGrid1
        .Row = 0
        .Col = 0
        .Rows = ms_rows + 1 'We add 1 to ensure we get all the rows
        .Cols = 2
        .ColWidth(0) = 250 ' CheckBox column
        .ColWidth(1) = 1440 ' Index column
    End With

    ' Now build the Grid

    For i = 0 To 20 'm_rows - 1
        With MSFlexGrid1
                .Row = i: .Col = 0: .CellPictureAlignment = 4 ' Align the checkbox
                Set .CellPicture = picUnchecked.Picture ' Set the default checkbox picture to the empty box
                .TextMatrix(i, 1) = i
        End With
    Next
End Sub
Private Sub MSFlexGrid1_Click()
Dim oldx, oldy, cell2text As String, strTextCheck As String

    ' Check or uncheck the grid checkbox
    With MSFlexGrid1
        oldx = .Col
        oldy = .Row
        If MSFlexGrid1.Col = 0 Then
            If MSFlexGrid1.CellPicture = picChecked Then
                Set MSFlexGrid1.CellPicture = picUnchecked
                .Col = .Col + 1 ' I use data that is in column #9, usually an Index or ID #
                strTextCheck = .Text
                strChecked = Replace(strChecked, strTextCheck & ",", "")
                Debug.Print strChecked
            Else
                Set MSFlexGrid1.CellPicture = picChecked
                .Col = .Col + 1
                strTextCheck = .Text
                strChecked = strChecked & strTextCheck & ","
                Debug.Print strChecked
            End If
        End If
        .Col = oldx
        .Row = oldy
    End With
End Sub

 

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
vb中msflexgrid的使用举例
VB MSFlexGrid控件的几种简单的使用方法
datagrid\mshflexgrid\msflexgrid的区别
怎样添加一个下拉框到msflexgrid
为MSHFlexGrid添加表格编辑功能
MSHFLEXGRID控件讲座(2).网格的编辑,保存与加载 VB / 控件 - CSDN...
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服