Sunday, 15 March 2015

winforms - How to add already existing ToolStrip Buttons to a ToolStrip Dynamically -


I have a WinFormon API using MII form, on MDI form I have a toolstrip with a button (in the button Images), working as the main menu button of the application. So when the user clicks the button on the toolstreet, the child's form opens with the mdichild form of that button.

That's why I have already made images and six buttons in the project but I want the user to select the button that appears on toolstrip. So the user opens the app and there is only one button on the toolstrip. The user clicks on that button and a child screen opens all available existing buttons which can be on toolstrip. The user chooses the buttons that want to appear on the toolstrip and then clicks on the screen to save the button on the screen.

What I need is that as soon as the user should click that button to save the button, automatically appear on the toolstrip. Now I have to close the application with the user and then click the button To open it, it must be opened to display it on the toolbar.

How can I get the button to automatically appear?

Just create all ToolStripButtons , and each Visible property to false . When users select them to be shown, change the property of visible to ToolStripButton to true . They will automatically appear on the ToolStrip .

I tested with Oxygen using RemObjects (formerly AKA Delphi Prism ) using VS2010.

  • Start a new WinForms application
  • Drop a ToolStrip on the window. Right-click on it and choose Insert Standard Item . Double-click the
  • new button ( newToolStripButton ), and add the following code to the newToolStripButton_Click handler:
     // Oxygen version: helpToolStripButton.Visible: helpToolStripButton.Visible; HelpToolStripButton.Visible! = HelpToolStripButton.Visible;  
    • Click the "code" newTooStripButton to run the application, and repeat the correct - most ToolStripButton ( help < / Code> View)> Button) appear by ToolStrip and disappear.

No comments:

Post a Comment