Solved

Checking All CheckBoxes in a DatagridView

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

9 Experts available now in Live!

Get 1:1 Help Now