Solved

Checking All CheckBoxes in a DatagridView

Posted on 2006-07-21
1
2,434 Views
Last Modified: 2008-02-01
Basically I have a datagridview that shows some information on an order and I want to check the box I want to print.  So when I hit my print button it will check all the rows that are selected and print them...

The problem I am having is figuring out how to select all.  What I want to do it select the Header Text at the top of the column and when i click that withthe mouse it will make the checkboxes in its column all set to checked

Here is how I added the checkbox to the datagridview


 Private Sub addSelectedForPrintingColumn()
        Dim column As New DataGridViewCheckBoxColumn()
        With column
            .HeaderText = "For Printing"
            .Name = "colSelectForPrinting"
            .Width = 110

            .FlatStyle = FlatStyle.Standard
            .CellTemplate = New DataGridViewCheckBoxCell()
            .CellTemplate.Style.BackColor = Color.Blue


        End With

        dgvDocketInformation.Columns.Insert(0, column)
    End Sub
0
Comment
Question by:foobarr
1 Comment
 
LVL 2

Accepted Solution

by:
Mystify earned 500 total points
ID: 17156865
   ' Assumes your datagridview control is called "grdList"

    Private Sub grdList_ColumnHeaderMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles grdList.ColumnHeaderMouseClick
        If e.ColumnIndex = grdList.Columns("colSelectForPrinting").Index Then
            Dim i As Integer
            For i = 0 To grdList.Rows.Count - 1
                grdList.Rows(i).Cells(e.ColumnIndex).Value = True
            Next
        End If
    End Sub
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now