Skip to content
Merged
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
82 changes: 45 additions & 37 deletions src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4409,32 +4409,36 @@ public bool ShowCellErrors
}
set
{
if (ShowCellErrors != value)
if (dataGridViewState2[DATAGRIDVIEWSTATE2_showCellErrors] != value)
{
dataGridViewState2[DATAGRIDVIEWSTATE2_showCellErrors] = value;

// Put this into OnShowCellErrorsChanged if created.
if (IsHandleCreated && !DesignMode)
{
if (value && !ShowRowErrors && !ShowCellToolTips)
if (!ShowRowErrors && !ShowCellToolTips)
{
// the tool tip hasn't yet been activated
// activate it now
toolTipControl.Activate(!string.IsNullOrEmpty(toolTipCaption));
}

if (!value && !ShowRowErrors && !ShowCellToolTips)
{
// there is no reason to keep the tool tip activated
// deactivate it
toolTipCaption = string.Empty;
toolTipControl.Activate(false /*activate*/);
if (value)
{
// The tool tip hasn't yet been activated
// activate it now
toolTipControl.Activate(!string.IsNullOrEmpty(toolTipCaption));
}
else
{
// There is no reason to keep the tool tip activated
// deactivate it
toolTipCaption = string.Empty;
toolTipControl.Activate(false /*activate*/);
}
}

if (!value && (ShowRowErrors || ShowCellToolTips))
else
{
// reset the tool tip
toolTipControl.Activate(!string.IsNullOrEmpty(toolTipCaption));
if (!value)
{
// Reset the tool tip
toolTipControl.Activate(!string.IsNullOrEmpty(toolTipCaption));
}
}

// Some autosizing may have to be applied since the potential presence of error icons influences the preferred sizes.
Expand Down Expand Up @@ -4463,35 +4467,39 @@ public bool ShowCellToolTips
}
set
{
if (ShowCellToolTips != value)
if (dataGridViewState2[DATAGRIDVIEWSTATE2_showCellToolTips] != value)
{
dataGridViewState2[DATAGRIDVIEWSTATE2_showCellToolTips] = value;

if (IsHandleCreated && !DesignMode)
{
if (value && !ShowRowErrors && !ShowCellErrors)
{
// the tool tip hasn't yet been activated
// activate it now
toolTipControl.Activate(!string.IsNullOrEmpty(toolTipCaption) /*activate*/);
}

if (!value && !ShowRowErrors && !ShowCellErrors)
if (!ShowRowErrors && !ShowCellErrors)
{
// there is no reason to keep the tool tip activated
// deactivate it
toolTipCaption = string.Empty;
toolTipControl.Activate(false /*activate*/);
if (value)
{
// The tool tip hasn't yet been activated
// activate it now
toolTipControl.Activate(!string.IsNullOrEmpty(toolTipCaption) /*activate*/);
}
else
{
// There is no reason to keep the tool tip activated
// deactivate it
toolTipCaption = string.Empty;
toolTipControl.Activate(false /*activate*/);
}
}

if (!value && (ShowRowErrors || ShowCellErrors))
else
{
bool activate = !string.IsNullOrEmpty(toolTipCaption);
Point mouseCoord = System.Windows.Forms.Control.MousePosition;
activate &= ClientRectangle.Contains(PointToClient(mouseCoord));
if (!value)
{
bool activate = !string.IsNullOrEmpty(toolTipCaption);
Point mouseCoord = System.Windows.Forms.Control.MousePosition;
activate &= ClientRectangle.Contains(PointToClient(mouseCoord));

// reset the tool tip
toolTipControl.Activate(activate);
// Reset the tool tip
toolTipControl.Activate(activate);
}
}
}

Expand Down