Hello there. I'm new to the site.
Not too sure if I have the right prefix for this thread, but I wanted to post a bit of code that allows for an entire column to be selected in a datagridview. I spent nearly eight hours looking for this code through various search engines and when I finally found it, it was in C#; thus I had to convert it to vb.net.
So I thought I would publish this for the interweb and those that are looking for what I was looking for, a way to select an entire column in a datagridview form control in vb.net.
Here it is:
and I have it in the following subroutine
Not too sure if I have the right prefix for this thread, but I wanted to post a bit of code that allows for an entire column to be selected in a datagridview. I spent nearly eight hours looking for this code through various search engines and when I finally found it, it was in C#; thus I had to convert it to vb.net.
So I thought I would publish this for the interweb and those that are looking for what I was looking for, a way to select an entire column in a datagridview form control in vb.net.
Here it is:
VB.NET:
Dim row As DataGridViewRow
For Each row In DataGrid1.Rows
row.Cells(e.ColumnIndex).Selected = True
and I have it in the following subroutine
VB.NET:
Private Sub DataGrid1_ColumnHeaderMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs)
Handles DataGrid1.ColumnHeaderMouseClick
Dim row As DataGridViewRow
For Each row In DataGrid1.Rows
row.Cells(e.ColumnIndex).Selected = True
Next
End Sub
Last edited: