我需要应用格式 - 具体而言,粗体文本 - 到由在虚拟模式下一个DataGridView使用的工具提示。我可以设置在CellToolTipTextNeeded事件中的文本,但它不支持HTML标签;在那里,我应该使用一些其他的语法?我不想重新实现提示养活自己。

有帮助吗?

解决方案

可以使用从HtmlToolTip http://www.codeproject.com/KB/GDI-plus/HtmlRenderer。 ASPX

To use it with DataGridView create a ToolTip (HtmlToolTip) and add this after the InitalizeComponent() in your form to replace the default tooltip:

System.Reflection.FieldInfo toolTipControlFieldInfo=
typeof(DataGridView).GetField("toolTipControl", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

System.Reflection.FieldInfo toolTipFieldInfo=
toolTipControlFieldInfo.FieldType.GetField("toolTip", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

object toolTipControlInstance =
toolTipControlFieldInfo.GetValue(myDataGridView);

toolTipFieldInfo.SetValue(toolTipControlInstance, myToolTip);

我使用.NET 3.5工作

其他提示

作为该事件的名称所暗示的,它只是想要显示的文本,它不会有格式。

如果你想要什么样大胆,或其他类型的格式,你将不得不处理工具的显示和绘图笔头自己。您可以使用工具提示控制的帮助,OwnerDraw属性设置为true和处理绘制事件,但请注意,你将极有可能重写电网在显著的方式进入该事件在适当的时候。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top