Results 1 to 3 of 3

Thread: [RESOLVED] [2005] Check all checkboxes in datagridview

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    Resolved [RESOLVED] [2005] Check all checkboxes in datagridview

    Hi guys,
    I have a datagridview and i import a worlsheet from a selected spreadsheet. All the data is imported to the datagridview. I have created a separate column at runtime which has checkboxes so that the user can select which rows they want.
    Now I was wondering whether it was possible to create a button that will check all the checkboxes in the datagridview if the user either wants all the rows selected or a vast majority of them (so they can unselect the ones they dont want)?
    I've been searching for the past hour or so and cant find anythin to help me so can anybody out there offer me something that might work?
    Thanks in advance

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Check all checkboxes in datagridview

    The Value of a DataGridViewCheckBoxCell is a Boolean value, so True is checked and False is unchecked. You need to loop through the rows of the grid and set the Value of the appropriate cell to True or False. For instance, if the boolean column is at index 4:
    VB Code:
    1. For Each row As DataGridViewRow In myDataGridView.Rows
    2.     row.Cells(4).Value = True
    3. Next row
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    Re: [2005] Check all checkboxes in datagridview

    Thanks works perfectly.

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