how to include checkbox in MsFlexgrid

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chandru8
    New Member
    • Sep 2007
    • 145

    how to include checkbox in MsFlexgrid

    hi everybody
    can anyone help me in this how to add a check box in flexgrid with sample code

    thanks in advance
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Originally posted by chandru8
    hi everybody
    can anyone help me in this how to add a check box in flexgrid with sample code

    thanks in advance
    Have a look here:


    Just tried it, it works!

    Here, just is case link becomes obsolete

    [CODE=VB]

    Const strChecked = "þ"
    Const strUnChecked = "q"

    Private Sub Form_Load()
    With MSFlexGrid1
    .Rows = 10
    .Cols = 3

    .AllowUserResiz ing = flexResizeBoth

    'name the cols
    For i = 1 To .Cols - 1
    .Row = 0
    .Col = i
    .Text = "Column " & i
    Next i

    'name the rows
    For i = 1 To .Rows - 1
    .Col = 0
    .Row = i
    .Text = "Row " & i
    Next i

    'define fields as checkbox
    For y = 1 To .Rows - 1
    For x = 1 To .Cols - 1
    .Row = y
    .Col = x
    .CellFontName = "Wingdings"
    .CellFontSize = 14
    .CellAlignment = flexAlignCenter Center
    .Text = strUnChecked
    Next x
    Next y
    End With

    End Sub

    Private Sub Form_Resize()
    MSFlexGrid1.Wid th = Me.ScaleWidth
    MSFlexGrid1.Hei ght = Me.ScaleHeight
    End Sub

    Private Sub TriggerCheckbox (iRow As Integer, iCol As Integer)
    With MSFlexGrid1
    If .TextMatrix(iRo w, iCol) = strUnChecked Then
    .TextMatrix(iRo w, iCol) = strChecked
    Else
    .TextMatrix(iRo w, iCol) = strUnChecked
    End If
    End With
    End Sub

    Private Sub MSFlexGrid1_Key Press(KeyAscii As Integer)
    If KeyAscii = 13 Or KeyAscii = 32 Then 'Enter/Space
    With MSFlexGrid1
    Call TriggerCheckbox (.Row, .Col)
    End With
    End If
    End Sub

    Private Sub MSFlexGrid1_Mou seDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = 1 Then
    With MSFlexGrid1
    If .MouseRow <> 0 And .MouseCol <> 0 Then
    Call TriggerCheckbox (.MouseRow, .MouseCol)
    End If
    End With
    End If
    End Sub
    [/CODE]

    Dököll
    Last edited by Dököll; Nov 30 '07, 06:13 AM. Reason: added remark

    Comment

    Working...