diff --git a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.cs b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.cs index 6b063e11644..b0a7a4cdb50 100644 --- a/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.cs +++ b/src/System.Windows.Forms/src/System/Windows/Forms/DataGridView.cs @@ -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. @@ -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); + } } }