c# – 工具提示气球显示位置(用于错误通知)

c# – 工具提示气球显示位置(用于错误通知),第1张

概述我前一段时间问了一个与此密切相关的问题: Alternative way to notify the user of an error 简而言之,我试图找到一种快速简便的方法,在不使用d出窗口的情况下通知用户错误. 现在我使用工具提示气球实现了这一点.问题是,即使我给它一个大致的位置,气泡的小尖头部分也会根据消息的大小改变位置(见附图).通常,我会使用SetToolTip()并为其分配一个控件,以 我前一段时间问了一个与此密切相关的问题:
Alternative way to notify the user of an error

简而言之,我试图找到一种快速简便的方法,在不使用d出窗口的情况下通知用户错误.

现在我使用工具提示气球实现了这一点.问题是,即使我给它一个大致的位置,气泡的小尖头部分也会根据消息的大小改变位置(见附图).通常,我会使用Settooltip()并为其分配一个控件,以便它始终指向该控件.但是,控件是状态栏中的标签或图像.

private voID ShowtooltipBalloon(string Title,string msg){    if (this.Invokerequired)    {        this.BeginInvoke(new EventHandler(delegate { ShowtooltipBalloon(Title,msg); }));    }    else    {        tooltip tt = new tooltip();        tt.IsBalloon = true;        tt.tooltipIcon = tooltipIcon.Warning;        tt.ShowAlways = true;        tt.Backcolor = color.FromArgb(0xFF,0xFF,0x90);        tt.tooltipTitle = Title;        int x = this.WIDth - lblleftTarget.WIDth - lblVersion.WIDth - toolStripStatusLabel8.WIDth - 10;        int y = this.Height - lblleftConnectimg.Height - 60;        tt.Show(msg,this,x,y,5000);    }}

这远远超出了要求的范围,但我的老板对于细节来说是一个坚持,所以除了解决这个问题,我必须快速解决它.我需要一些相对容易实现的东西,它不会“摇摆”我即将发布的当前软件.

话虽这么说,我当然会听取任何建议,无论是否可实施.至少我可能会学到一些东西.

*编辑:似乎我的图像没有显示.我不知道这只是我的电脑.那好吧…

解决方法 我知道这是一个相当古老的问题,我想我已经错过了近4年的交付期限……但我相信这可以解决您遇到的问题:

private voID ShowtooltipBalloon(string Title,msg); }));    }    else    {        // the designer hooks up to this.components        // so lets do that as well...        tooltip tt = new tooltip(this.components);        tt.IsBalloon = true;        tt.tooltipIcon = tooltipIcon.Warning;        tt.ShowAlways = true;        tt.Backcolor = color.FromArgb(0xFF,0x90);        tt.tooltipTitle = Title;        // Hookup this tooltip to the statusstrip control        // but DON'T set a value         // because if you do it replicates the problem in your image        tt.Settooltip(this.statusstrip1,String.Empty);         // calc x        int x = 0;        foreach (ToolStripItem tbi in this.statusstrip1.Items)        {            // find the toolstrip item            // that the tooltip needs to point to            if (tbi == this.toolstripdropdownbutton1)              {                break;            }            x = x + tbi.Size.WIDth;        }        // guestimate y         int y = -this.statusstrip1.Size.Height - 50;        // show it using the statusstrip control         // as owner        tt.Show(msg,this.statusstrip1,5000);    }}
总结

以上是内存溢出为你收集整理的c# – 工具提示气球显示位置(用于错误通知)全部内容,希望文章能够帮你解决c# – 工具提示气球显示位置(用于错误通知)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1227536.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-05
下一篇 2022-06-05

发表评论

登录后才能评论

评论列表(0条)

保存