先看效果:
https://www.bilibili.com/video/BV1294y1w7Lm/?vd_source=0b221dbd75584a13ab6cd4551f3a0ec2
需要用到的dll
C:\AVEVA\Marine\OH12.1.SP4\ExplorerControl.dll
C:\AVEVA\Marine\OH12.1.SP4\Infragistics.Win.dll
C:\AVEVA\Marine\OH12.1.SP4\Infragistics.Win.UltraWinTree.dll
完整的代码
[MyAmFunctionAtt(nameof(测试功能), nameof(显示toolTip的内容))]
public static void 显示toolTip的内容(WindowManager wm)
{
try
{
var de = wm.Windows.Cast<IWindow>().FirstOrDefault(c => c.Title == "Design Explorer") as DockedWindow;
var ut = de.Control.Controls[0] as Infragistics.Win.UltraWinTree.UltraTree;
//de.Tooltip = "";
if (ut != null)
{
//UltraToolTipManager uttm = new UltraToolTipManager();
var tt = new Infragistics.Win.ToolTip(ut)
{
AutoPopDelay = 8000,
InitialDelay = 1000,
BorderStyle = Infragistics.Win.ToolTipBorderStyle.Solid,
DisplayStyle = Infragistics.Win.ToolTipDisplayStyle.BalloonTip,
ForeColor = System.Drawing.Color.Blue,
BackColor = System.Drawing.Color.LightYellow,
//tt.DisplayStyleResolved = Infragistics.Win.ToolTipDisplayStyle.WindowsVista;
CustomToolTipImage = Properties.Resources.logo,
ToolTipTitle = "增强属性",
//tt.ToolTipTextStyle = Infragistics.Win.ToolTipTextStyle.Formatted;
TopMost = true,
};
ut.MouseEnterElement += (s, e) =>
{
try
{
var pos = ut.PointToClient(System.Windows.Forms.Control.MousePosition);
var anode = ut.GetNodeFromPoint(pos);
if (anode == null) return;
var etd = anode as ExplorerTreeNode;
if (etd == null) return;
//tt.UseAppStyling = true;
var ele = etd?.Element;
StringBuilder sb = new StringBuilder();
sb.AppendLine($"Description:{ele.GetActualType().Description}");
sb.AppendLine($"RefNo:{ele.GetAsString(DbAttributeInstance.REF)}");
sb.AppendLine($"Name:{ele.GetAsString(DbAttributeInstance.NAMETY)}");
sb.AppendLine($"CLMID:{ele.GetAsString(DbAttributeInstance.CLMID)}");
sb.AppendLine($"UserLastMod:{ele.GetAsString(DbAttributeInstance.USERM)}");
sb.AppendLine($"Userclaim:{ele.GetAsString(DbAttributeInstance.USERC)}");
sb.AppendLine($"DateLastMod:{ele.GetAsString(DbAttributeInstance.LASTM)}");
tt.ToolTipText = sb.ToString();
tt.Show();
}
catch (Exception ex)
{
Interaction.MsgBox(ex.Message, MsgBoxStyle.Critical);
}
};
ut.MouseLeaveElement += (s, e) => { tt.Hide(); };
}
}
catch (System.Exception ex)
{
Interaction.MsgBox(ex.Message, MsgBoxStyle.Exclamation);
}
}
标签:C#,Win,tt,Infragistics,ele,鼠标悬停,var,sb,MARINE From: https://www.cnblogs.com/NanShengBlogs/p/17924727.html