Solved

Checking All CheckBoxes in a DatagridView

Posted on 2006-07-21
1
2,441 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 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

691 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