Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Checking All CheckBoxes in a DatagridView

Posted on 2006-07-21
1
Medium Priority
?
2,445 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

Accepted Solution

by:
Mystify earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

636 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