禁用某些单元格的工具提示

我的Windows窗体中有一个gridview.现在,我使用以下代码显示自定义工具提示,

private void Audit_Dg_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)


{
          if (e.ColumnIndex == 7 || e.ColumnIndex == 8 || e.ColumnIndex == 10 || e.ColumnIndex == 11 && e.RowIndex >= 0)
          {           
              DataGridViewCell cell = this.Audit_Dg.Rows[e.RowIndex].Cells[e.ColumnIndex];

          cell.ToolTipText = "Click Here To View The Message";


      }
}

它显示了有关满足我条件的那些单元格的消息,而所有不满足我条件的那些单元格的内容.有什么方法可以从我的网格视图中删除该工具提示并仅显示我的自定义工具提示?
如果有什么办法,请帮助我…

解决方法:

不幸的是,DataGridView控件不支持此功能.其ShowCellToolTips属性只能用于全局禁用工具提示.显示工具提示的情况记录为:

  • The value of the DataSource property is not null or the value of the VirtualMode property is true, and a handler for the
    CellToolTipTextNeeded event sets the
    DataGridViewCellToolTipTextNeededEventArgs.ToolTipText property to a
    value other than String.Empty.

  • The ToolTipText property of the cell has a value other than String.Empty. Setting this property has no effect when there is a
    CellToolTipTextNeeded event handler because getting the value of the
    property automatically raises the event and returns the ToolTip text
    specified in the event handler.

  • The cell value is truncated in the cell display. When the value of the cell ToolTipText property value is String.Empty, the full
    value of the truncated cell value is displayed in the ToolTip.

如您所见,无法避免第三种情况:如果ShowCellToolTips为true并且单元格的值被截断,则将显示包含完整值的工具提示.

上一篇:使用HTML javafx的工具提示


下一篇:Java获取鼠标悬停工具提示文本