获取工具条
问题描述:
大家好!
在我的应用程序中,我使用
创建了一个工具条
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)