Windows Develop Bookmark and Share   
 index > Windows Forms General > Adding items to toolstrip
 

Adding items to toolstrip

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

subhanet  Thursday, June 22, 2006 11:43 AM

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?

Brendan Grant  Thursday, June 22, 2006 1:48 PM

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?

Brendan Grant  Thursday, June 22, 2006 1:48 PM
hey thanx for ur reply it works fine ....
subhanet  Monday, June 26, 2006 4:12 AM

You can use google to search for other answers

Custom Search

More Threads

• multi-line textbox
• Drawstring alingment problem
• Fill a dropdown list items from a table column
• TableLayoutPanel Question
• How to catch general exception properly in Windows form?
• OnHandleCreated, IsHandleCreated: some threading issue makes me crazy :(
• ListView quirkiness
• creating an event to fire when a variable changes
• Win32 API to launch Windows Form immediately
• help how to display