Adding items to toolstrip  
Author Message
subhanet





PostPosted: Windows Forms General, Adding items to toolstrip Top

hi frnds,

i m new to C# . I want to add a button to a toolstrip at runtime . I mean it should be a toolstrip button. The problem is i m not able to add it dynamically . Any links will be helpful.

thanx in advance

.netguy



Windows Forms17  
 
 
Brendan Grant





PostPosted: Windows Forms General, Adding items to toolstrip Top

Adding a new button to a ToolStrip is quite easy and involves 2 parts. First you need only create the button and set any kind of properties you desire for it:

            ToolStripButton newButton = new ToolStripButton("My New Button");

           

            newButton.Click += new EventHandler(newButton_Click); //Setup event handling function (you would need to build this function on your own or have Intellisense make it for you)

            newButton.Image = someImage; //if desired

And finally add it to the ToolStrip that will be it’s parent with the Add() method of the Items property:

            toolStrip1.Items.Add(newButton);

Does this work for you



 
 
.netguy





PostPosted: Windows Forms General, Adding items to toolstrip Top

hey thanx for ur reply it works fine ....