Dumb datagridview column header question!

B

Bill Nguyen

I can't figure out how to identify/display the column header name in
Mouseclick event.
This is a checkbox column type and I would like all cells in this column to
toggle checked/unchecked when the user clicks on the column header.
YOur help is greatly appreciated.

Bill
 
P

PlatinumBay

Bill,

Try handling the ColumnHeaderMouseClick of the DataGridView.

Hope this helps,


Steve
 
B

Bill Nguyen

I can do this but how do I know which column contain the clumnheader being
clicked/selected?

Thanks again

Bill
 
P

PlatinumBay

Bill,

What about something like this?

Private Sub DataGridView1_ColumnHeaderMouseClick(ByVal sender As Object,
ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles
DataGridView1.ColumnHeaderMouseClick
If TypeOf Me.DataGridView1.Columns(e.ColumnIndex) Is
DataGridViewCheckBoxColumn Then
For Each row As DataRow In Me.DataGridView1.Rows
CType(row.Item(e.ColumnIndex),
DataGridViewCheckBoxCell).Value = True
Next
End If
End Sub

Hope this helps,


Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top