Placing a Checkbox in a FlexGrid Cell
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: Placing a Checkbox in a FlexGrid Cell

  1. #1
    Join Date
    Mar 2000
    Posts
    292

    Placing a Checkbox in a FlexGrid Cell

    I have a MSFlexGrid control on my form. How can I place a checkbox control on specified cells of the grid upon loading? I have this sample code, but doesn't do the way I intend it to:

    Dim intNextIndex As Integer

    For I = 1 To 10
    For J = 1 To 5
    ' Find the next available index
    intNextIndex = Check1().Count + 1
    ' Add the new checkbox on the form
    Load Check1(intNextIndex)
    ' Position the checkbox on the flexgrid's cell
    With Check1(intNextIndex)
    .Top = MSFlexGrid1.Top + MSFlexGrid1.CellTop
    .Left = MSFlexGrid1.Left + MSFlexGrid1.CellLeft
    .Width = MSFlexGrid1.CellWidth
    .Height = MSFlexGrid1.CellHeight
    ' By default, the new checkbox is not visible
    .Visible = True
    End With
    Next J
    Next I


    I have an invisible checkbox control placed on the form already, called Check1, with Index = 0. This code is just part of a long code which puts data and formats them on the grid all at run-time. The checkboxes are loaded dynamically from row 1 to 10, from column 1 to 5. Since checkboxes are not easily placed in the grid cells like simple text does, I have to load them during run-time. The next available index of a checkbox control array is taken, then the new checkbox is loaded and positioned in the specified cell.

    Does anyone have a suggestion why this doesn't work?

  2. #2
    Join Date
    May 2002
    Location
    Colombo,Sri Lanka
    Posts
    1,110
    good example in vb-helper.com
    Attached Files Attached Files

  3. #3
    Join Date
    Mar 2000
    Posts
    292

    Placing a Checkbox in a FlexGrid Cell

    Thank you, dinesh for the attached sample. That answered my question! I have another question though: I need to determine the name/caption of the row and the column where the user clicked. These will be passed as parameters to another form. How can I do that?

    Thanks again in advance!

  4. #4
    Join Date
    May 2002
    Location
    Colombo,Sri Lanka
    Posts
    1,110
    Flexgrid1.Text = is the text which contains the Clicked Cell

    ?MSFlexGrid1.TextMatrix(0,Flexgrid1.Col ) = Give u the Column name of the currently clicked Cell

    I'm not sure whether I answerd RU question.

  5. #5
    Join Date
    Mar 2000
    Posts
    292
    Thanks again, dinesh. Yes, you answered my question very well. I just modified your code to get different row and column names. I hope to contact you again in case I have new questions regarding flexgrid manipulations.

  6. #6
    Join Date
    May 2002
    Location
    Colombo,Sri Lanka
    Posts
    1,110
    Yes UR welcome.

    I learn lot from this forum.So I'm willing to help the people,from the little things that I know.

  7. #7
    Join Date
    Mar 2000
    Posts
    292
    Hello again dinesh. It's me daneb. I just want to ask how can I trigger the click event of the picture containing the checkbox in the flexgrid cell? I put a code in the Picture_Click() event, but it doesn't fire when I click on a flexgrid cell; instead the code located in the MSFlexGrid_Click() event is the one being activated. The flexgrid's click event overrides the picture's click event. How can I make the picture respond to an event such as this? Thanks!

  8. #8
    Join Date
    May 2002
    Location
    Colombo,Sri Lanka
    Posts
    1,110
    That is bcos we Set MSFlexGrid1.CellPicture = picUnchecked
    After that picture is a part of the msflexgrid.

  9. #9
    Join Date
    Mar 2000
    Posts
    292
    Hi. So, is there no way that the picture box can respond to the click or to any event? Can we place the picture box on top of each cell of the grid, instead of embedding it in the flexgrid?

  10. #10
    Join Date
    May 2002
    Location
    Colombo,Sri Lanka
    Posts
    1,110
    Yes u can

    There is a sample which I put combo box on the flex grid.
    I will attached it for u.
    Attached Files Attached Files

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center