CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2001
    Posts
    71

    Inserting Checkbox in flexgrid

    Hi,
    I know that u can insert text as well as picture in flex grid but how can I add any other component in one of the column of flex grid

    e.g. I want to insert a checkbox in the second column of flex grid or any other grid


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Inserting Checkbox in flexgrid

    '2 pictures on the form picChecked and picUnchecked

    Private Sub SetRow(ByVal idx As Integer, ByVal person_name As String, ByVal needs_air As Boolean, ByVal needs_hotel As Boolean, ByVal needs_car As Boolean)
    With MSFlexGrid1
    .TextMatrix(idx, 0) = person_name
    .Row = idx

    .Col = 1
    If needs_air Then
    Set .CellPicture = picChecked.Picture
    Else
    Set .CellPicture = picUnchecked.Picture
    End If

    .Col = 2
    If needs_hotel Then
    Set .CellPicture = picChecked.Picture
    Else
    Set .CellPicture = picUnchecked.Picture
    End If

    .Col = 3
    If needs_car Then
    Set .CellPicture = picChecked.Picture
    Else
    Set .CellPicture = picUnchecked.Picture
    End If
    End With
    End Sub
    Private Sub Form_Load()
    With MSFlexGrid1
    .BackColor = &HE0E0E0
    .Rows = 4
    .Cols = 4
    .FixedCols = 1
    .FixedRows = 1

    .TextMatrix(0, 0) = "Name"
    .TextMatrix(0, 1) = "Air"
    .TextMatrix(0, 2) = "Hotel"
    .TextMatrix(0, 3) = "Car"
    End With

    SetRow 1, "Alice", True, True, False
    SetRow 2, "Bob", True, False, False
    SetRow 3, "Carter", False, False, True
    End Sub

    Private Sub Form_Resize()
    MSFlexGrid1.Move 0, 0, ScaleWidth, ScaleHeight
    End Sub


    ' Toggle the check box.
    Private Sub MSFlexGrid1_Click()
    If MSFlexGrid1.Col < 1 Or MSFlexGrid1.Row < 1 Then Exit Sub

    If MSFlexGrid1.CellPicture = picChecked Then
    Set MSFlexGrid1.CellPicture = picUnchecked
    Else
    Set MSFlexGrid1.CellPicture = picChecked
    End If
    End Sub


    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured