gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 16:21:54 25 4
gpt4 key购买 nike

我的窗口窗体中有一个 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";


}
}

它为满足我的条件的那些单元格显示我的消息,而所有那些不满足我的条件的单元格内容。有没有办法从我的 GridView 中删除该工具提示并仅显示我的自定义工具提示?如果有什么办法,请帮助我...

最佳答案

很遗憾,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.

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

关于c# - 禁用某些单元格的工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12854293/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com