C# Visual Studio 2005中修改toolStrip的内容

今天修改一个C#程序的debug。其中有一个debug,我在我的程序里添加了一个toolStrip,然后在其上面添加了几个按钮,如toolStripButton1、toolStripButton2、toolStripButton3等多个按钮,然后我用编程的方式改变它的ToolTipStrip代码如下:

toolStripButton1.ToolTipText = "New File";

但是很遗憾没有修改过来,程序运行以后它的ToolTip仍然为toolStripButton1,没有修改过来。我抓破头皮想了很多办法,查了MSDN,MSDN如是说:

ShowItemToolTips 设置为 true 时,ToolTipText 才有效。如果 AutoToolTip 设置为 true,则该项的 Text 属性将用作 ToolTipText

只有当

internal ToolStripButton imageButton;

private void InitializeImageButtonWithToolTip()
{

    // Construct the button and set the image-related properties.
    imageButton = new ToolStripButton();
    imageButton.Image = new Bitmap(typeof(Timer), "Timer.bmp");
    imageButton.ImageScaling = ToolStripItemImageScaling.SizeToFit;

    // Set the background color of the image to be transparent.
    imageButton.ImageTransparentColor = Color.FromArgb(0, 255, 0);

    // Show ToolTip text, set custom ToolTip text, and turn
    // off the automatic ToolTips.
    toolStrip1.ShowItemToolTips = true;
    imageButton.ToolTipText = "Click for the current time";
    imageButton.AutoToolTip = false;

    // Add the button to the ToolStrip.
    toolStrip1.Items.Add(imageButton);

}
 

但是非常遗憾,问题依然从在。

于是猛的想起还可以在toopStripButton的属性框中修改。哈哈,这一修改竟然成功了。

也有个比较遗憾的问题是我不知道为什么象我用编程的方式那样写还是不行,如果你知道,请给我留言。

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值