Winforms: The CellFormatting event of datagridview cannot be fired for cells that are not headers

Created on 8 Oct 2019  路  7Comments  路  Source: dotnet/winforms

  • .NET Core Version: (3.1.100-preview1-14455 from release branch)
  • Have you experienced this same bug with .NET Framework?: No

Minimal repro:

  1. Build and run the attached application.
    CellFormattingEvent.zip
  2. Double click on "D" cell, so that entire cell cannot be selected(only selected cell 's text).
  3. Then focus on(not click) the first cell of "A".
    ReproSteps gif

Actual behavior:
The CellFormatting event of datagridview cannot be fired, and the tooltip will display .

Expected behavior:
The CellFormatting event of datagridview should be fired.

bug regression

Most helpful comment

We would not expect the CellFormatting event to fire until the user leaves the cell that is being edited. Simply hovering elsewhere doesn't end the editing of the cell and it's when the editing is done that I would expect the CellFormatting would fire. I'd argue that not triggering the event when hovering over another cell is what I'd expect. @M-Lipin just mention this when you document #1680

All 7 comments

This looks like a regression introduced in https://github.com/dotnet/winforms/pull/1681
Prior to #1681 CellFormatting event would be raised on cell hover, however now a tooltip is shown and the event isn't raised.

@vladimir-krestov please see what we can do to restore the original behaviour and have the tooltips.

Ok, I'll investigate this.

I have investigated a case when added a ToolTip text for a TextBox cell (without #1681 changes):

image

I have got the following result:

otF94hrOSp

小onclusion:

1681 changes added default tooltips for all cells ("Edit" or cell Value for DataGridViewTextBoxCell for example)

@Amy-Li02 could you please check this?

@RussKie @merriemcgaw @Tanya-Solyanik could you please say what implementation we need?
At the moment everything works correctly because if a cell has a tooltip CellFormatting event is not fired in this specific case as before.
Or do we need to call CellFormatting event in this case regardless of tooltips?

Did this scenario call the CellFormatting event in Framework?

@merriemcgaw @vladimir-krestov Yes, your investigation result is right.

  1. In .NET Core, added default tooltips for all cells, so CellFormatting event is not fired.
  2. In .NET Framework, there is no default tooltips for all cells, so by default, CellFormatting event can be fired. However when added a ToolTip text for a TextBox cell, CellFormatting event is not fired.

Now we worried CellFormatting event will never be fired when hover a cell in core app.

@merriemcgaw, @Amy-Li02 does it need to implement calling CellFormating event when hovering a cell by mouse regardless of tooltips?
At the moment a DataGridView cell has a tooltip always. Except when the user sets an empty string or nullas a tooltip text (then CellFormating event is fired).

Also, if you set dataGridView1.ShowCellToolTips = false; then CellFormatting event is not fired.
3

We would not expect the CellFormatting event to fire until the user leaves the cell that is being edited. Simply hovering elsewhere doesn't end the editing of the cell and it's when the editing is done that I would expect the CellFormatting would fire. I'd argue that not triggering the event when hovering over another cell is what I'd expect. @M-Lipin just mention this when you document #1680

Was this page helpful?
0 / 5 - 0 ratings