Get column name

gate7cy

Well-known member
Joined
May 11, 2009
Messages
119
Programming Experience
3-5
I have a datagridview in a winform for my .net application. Using access 07 for db. I am trying to retrieve the name of the selected column but I have found nothing available to assist me. This is what I do on the ColumnheaderMouseClick event :

VB.NET:
 Dim criteria As Integer
        criteria = CInt(AllServicesDataGridView.SelectedColumns.ToString)


        Dim xx As String
        xx = AllServicesDataGridView.Columns(criteria).HeaderText
        TextBox1.Text = xx


With this this I get this exception

conversion from string "System.Windows.forms.datagridview to type integer is not valid

thanks for all the help.
 
Back
Top