获取工具条 [英] getting items of toolstrip

查看:66
本文介绍了获取工具条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

在我的应用程序中,我使用
创建了一个工具条 button1
button2
button3
button4
button5

最初,所有按钮的可见性均为假

我创建了一个我想将按钮的可见性设置为true的函数

我通过索引做到了

但我想使用文本(例如button1,button2,.....)


hi to all!

in my application i create a toolstrip with
button1
button2
button3
button4
button5

initially all button visibility is false

i create one function in which i want to set the visibility of button as true

i done that by index

but i want to do it with text (like button1, button2,.....)


private void toolStrip2_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
      {
          for (int i = 0; i < toolStrip2.Items.Count; i++)
          {
              if (toolStrip2.Items[i].Selected)
              {
                  int A = i;
                  switch (i)
                  {
                      case 0:
                          statement1
                          break;

                      case 1:
                          statement2
                          break;

                      case 2:
                          toolStrip2.Visible = false;
                          statement3
                          break;


等等

[edit]添加了代码块,将我的内容作为纯文本..."选项已禁用-OriginalGriff [/edit]


and so on

[edit]Code block added, "Treat my content as plain text..." option disabled - OriginalGriff[/edit]

推荐答案

然后使用ToolStripButton的名称创建并添加到ToolStrip的对象-如果在设计窗口中查看Tool strip的属性,应该会发现它们每个都有一个名称(默认名称为toolStripButton1,toolStripButton2等)
Then use the name of the ToolStripButton that you created and added to the ToolStrip - if you look in the properties of the Tool strip in the design window you should find they each have a name (the default is toolStripButton1, toolStripButton2 and so forth)


这篇关于获取工具条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆