C# 如何在用户控件上显示文本气泡?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/806420/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 01:58:52  来源:igfitidea点击:

C# How to show a text bubble on a user control?

c#.netwinformsuser-interface

提问by mafu

I'm developing an user control in .NET 3.5. As reaction to some event, I would like to show a simple bubble containing a short text on this control, similar to the well-known system tray notification bubbles. I'm sure this is a very easy task, could you give me a quick hint?

我正在 .NET 3.5 中开发用户控件。作为对某些事件的反应,我想在此控件上显示一个包含简短文本的简单气泡,类似于众所周知的系统托盘通知气泡。我确定这是一项非常简单的任务,你能给我一个快速提示吗?

采纳答案by jonny

use ToolTip

使用工具提示

System.Windows.Forms.ToolTip myToolTip = new System.Windows.Forms.ToolTip();
myToolTip.IsBalloon = true;
myToolTip.Show("Some text", this.WhereToShow);

回答by jEROD

you can use a popup control for this (in WPF)

您可以为此使用弹出控件(在 WPF 中)

MSDN

MSDN

回答by Tim Robinson

Use the ToolTipclass -- set IsBalloon= trueto get the bubble effect.

使用ToolTip类--set IsBalloon=true获得气泡效果。

回答by Nathan Ridley

Drop a NotifyIconcontrol onto your form, then call the ShowBalloonTipmethod of your control.

NotifyIcon控件拖放到窗体上,然后调用控件的ShowBalloonTip方法。

System.Windows.Forms.NotifyIcon myIcon; // generated by the designer
// more designer code, then your code:
myIcon.ShowBalloonTip(3000, "My Title", "My Text", someIconReference);