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

来源:互联网 发布:北风网大数据视频下载 编辑:程序博客网 时间:2024/06/11 09:07

今天修改一个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的属性框中修改。哈哈,这一修改竟然成功了。

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

 

原创粉丝点击