Click here to Skip to main content
15,903,012 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi every body,
Now i wanna get selected header name when i using dataGridView1_MouseDown. Can you help me, please? Thank you so much :D :D :D
Posted
Comments
syed shanu 7-Dec-14 23:02pm    
Why do you want Mousedown Event.You can use Cell Click or CellContent Colick event.

Here is the code to get the Header Name from Datagridview Mouse Down event

C#
  private void Datagridview1_MouseDown(object sender, MouseEventArgs e)
         {

             MessageBox.Show("Column Name :  " + this.Datagridview1.Columns[Datagridview1.HitTest(e.X, e.Y).ColumnIndex].Name);

MessageBox.Show("Column Name :  " + this.Datagridview1.Columns[Datagridview1.HitTest(e.X, e.Y).ColumnIndex].HeaderText);

         }
 
Share this answer
 
v2
Yeah, thank so much everyone, syed shanu answer is right :D
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900