c#tooltip的使用和动态显示提示信息

效果图

 

// This example assumes that the Form_Load event handling method

// is connected to the Load event of the form.

private void Form1_Load(object sender, System.EventArgs e)

{

// Create the ToolTip and associate with the Form container.

ToolTip toolTip1 = new ToolTip();

 

// Set up the delays for the ToolTip.

toolTip1.AutoPopDelay = 5000;

toolTip1.InitialDelay = 1000;

toolTip1.ReshowDelay = 500;

// Force the ToolTip text to be displayed whether or not the form is active.

toolTip1.ShowAlways = true;

 

// Set up the ToolTip text for the Button and Checkbox.

toolTip1.SetToolTip(this.button1, "My button1");

toolTip1.SetToolTip(this.checkBox1, "My checkBox1");

}

可以自己在form_load里面new一个,但这个办法,只能显示固定内容的东西,要想显示动态的提示信息,最好还是在控件界面拖一个ToolTip然后再form_load里面设置好一些属性,然后SetToolTip这句话先不写,等你需要展示的控件内容更新之后再把这句话加上,

例:我的是需要在combobox上面显示,所以我set的地方是在cmbExcelIndex_SelectedIndexChanged(自己重写的改变事件里面)设置

toolTip.SetToolTip(this.cmbExcelIndex, this.cmbExcelIndex.Text);

 

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

搁浅的渔

创作不易,多多支持

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值