Reputation: 115
I want to take the ColumnHeader Text of the ColumnHeader that has been double clicked. This is what I've gotten so far. It doesn't work. Can anyone help?
private void dataGridView1_ColumnHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
string TheDate = dataGridView1.SelectedColumns.ToString();
MessageBox.Show(TheDate);
}
Upvotes: 2
Views: 2451
Reputation: 1441
Try that:
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
string theDate = dataGridView1.Columns[e.ColumnIndex].Name;
}
Upvotes: 2
Reputation: 148110
You can get index of column through DataGridViewCellMouseEventArgs
object e and use to get the HeaderText
string text = dataGridView1.Columns[e.ColumnIndex].HeaderText;
Upvotes: 2