How to disable double click on the header of a DataGrid?

0

Double-click grid method:

    private void grid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
    {
      if (e.LeftButton == MouseButtonState.Pressed && //Verifica clique com o esquerdo
          uldPo00100.SelectedItems.Count > 0) //Verifica item selecionado 
          //Comandos para abrir nova janela

Normally, in the simple click, a grid item is selected, and in the double click, it performs the above method.

Problem: When an item is selected, and double click on the heading, or the white part of the grid, the same method is executed.

Is there a check if the double-click is on the same line, or different from the header? Or is there a click event in the header? Remembering DataGrid is not DataGridView ..

    
asked by anonymous 26.03.2017 / 22:58

2 answers

0

Remove the event handler

 EventHandler eventHandler = new EventHandler(dataGridView_CellContentDoubleClick);
 dataGridView.CellContentDoubleClick -= eventHandler; 
    
27.03.2017 / 13:38
0

I believe it is not possible to disable. Alternatively you can skip the double click on the heading:

private void grid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
    DataGridView.HitTestInfo hit = grid.HitTest(e.X, e.Y);
    if (hit.Type == DataGridViewHitTestType.ColumnHeader)
    {
        return;
    }
}
    
27.03.2017 / 13:53