Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -516,14 +516,6 @@ OwningColumn is null ||
return Rectangle.Empty;
}

Point ptCurrentCell = DataGridView.CurrentCellAddress;
if (ptCurrentCell.X == ColumnIndex &&
ptCurrentCell.Y == rowIndex && DataGridView.IsCurrentCellInEditMode)
{
// PaintPrivate does not paint the error icon if this is the current cell.
// So don't set the ErrorIconBounds either.
return Rectangle.Empty;
}

ComputeBorderStyleCellStateAndCellBounds(
rowIndex,
Expand Down Expand Up @@ -1073,16 +1065,11 @@ private Rectangle PaintPrivate(
valBounds.Width -= borderWidths.Right;
valBounds.Height -= borderWidths.Bottom;
bool cellSelected = (elementState & DataGridViewElementStates.Selected) != 0;
bool drawAsMixedCheckBox = false, drawErrorText = true;
bool drawAsMixedCheckBox = false;
CheckState checkState;
ButtonState bs;
Debug.Assert(DataGridView is not null);
Point ptCurrentCell = DataGridView.CurrentCellAddress;
if (ptCurrentCell.X == ColumnIndex &&
ptCurrentCell.Y == rowIndex && DataGridView.IsCurrentCellInEditMode)
{
drawErrorText = false;
}

if (formattedValue is not null and CheckState state)
{
Expand Down Expand Up @@ -1554,7 +1541,7 @@ private Rectangle PaintPrivate(
resultBounds = Rectangle.Empty;
}

if (paint && PaintErrorIcon(paintParts) && drawErrorText && DataGridView.ShowCellErrors)
if (paint && PaintErrorIcon(paintParts) && DataGridView.ShowCellErrors)
{
PaintErrorIcon(g, cellStyle, rowIndex, cellBounds, errorBounds, errorText);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,30 @@ public void DataGridViewCell_ContentBounds_GetWithColumn_ReturnsExpected()
Assert.Equal(Rectangle.Empty, cell.ContentBounds);
}

[WinFormsFact]
public void DataGridViewCheckBoxCell_ErrorIconBounds_RemainsVisible_InEditMode()
{
using DataGridView dgv = new()
{
Size = new Size(100, 40),
ShowCellErrors = true
};
dgv.CreateControl();

using DataGridViewCheckBoxColumn column = new();
dgv.Columns.Add(column);
dgv.Rows.Add();

var cell = (DataGridViewCheckBoxCell)dgv.Rows[0].Cells[0];
cell.Value = false;
cell.ErrorText = "err";

dgv.CurrentCell = cell;
dgv.BeginEdit(true);

Assert.NotEqual(Rectangle.Empty, cell.ErrorIconBounds);
}

[WinFormsFact]
public void DataGridViewCell_ContentBounds_GetWithDataGridView_ReturnsExpected()
{
Expand Down
Loading