CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2000
    Posts
    11

    Bringing CheckBox to a column of a Grid Control

    Hi all,
    I am developing an application where by I need to give the provision to delete records for some days from the DB, for which I wish to give a UI which has a FlexiGrid with two columns. The first column show the date for which the records need to be deleted. Second column is to get the consent from the user whether to delete the record or not. How do I bring the checkbox feature in the column. Can any of you help me out. Thanking you in advance.
    Saju


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

    Re: Bringing CheckBox to a column of a Grid Control

    'You can do it with 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]

  3. #3
    Join Date
    May 2001
    Posts
    36

    Re: Bringing CheckBox to a column of a Grid Control

    Use EasyGrid instead of FlexGrid.
    You may download it from http://www.share2.com/easygrid/
    There is a .DoSetDroplistCell as follows:
    void DoSetDroplistCell(long col, long row, LPCTSTR items, BOOL hidetag, BOOL readonly)

    Return Value:
    None.
    Parameters:
    col the number of the column where the cell located
    row the number of the row where the cell located
    items texts of droplist
    hidetag When selected cell is not current cell, whether hide droplist box
    readonly whether the item in drop list is editable

    Remarks:
    Set current cell drop list cell.


    Items in drop list are separated by “\n?

    See also
    DoSetNormalCell


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