tags:

views:

219

answers:

1

Hey, im working on a project and i have to get the name(header text) of selected column in my listbox or textbox from datagridview, when i select any column it shows the name of that column in textbox or listbox.. i'll be very thankful to if you guys kindly help me out in this matter..

im trying to use the code on DataGridViewHeaderClickEvent "textBox1.Text=dataGridView1.SelectedColumns.ToString();"

A: 

Try something like this:

if (dataGridView1.SelectedColumns.Count > 0)
    textBox1.Text=dataGridView1.SelectedColumns[0].Name;
else
    textBox1.Text="";
Justin Grant