E
E
evgeniy_matveev2019-09-23 10:26:35
C++ / C#
evgeniy_matveev, 2019-09-23 10:26:35

Handle click event on DGV header?

Good afternoon. I'm using the RowHeaderMouseClick event to call the context menu in the DGV. But when you click on this area of ​​the selected area , the 5d88714c34eef853707134.jpegevent does not occur. In general, it is clear why. The question is, what event to process when clicking on this area?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Foggy Finder, 2019-09-23
@evgeniy_matveev

Handle the generic CellMouseClick event . The cell selected in the screenshot has both indices equal to -1:

private void DataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
    var row = e.RowIndex;
    var column = e.ColumnIndex;

    if(row == -1 && column == -1)
    {
        // Do something
    }
}

W
Wundarshular, 2019-09-23
@Wundarshular

In theory, this is the header area of ​​the table grid. Have you tried DataGridView.ColumnHeaderMouseClick?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question