I am designing a series of ToolStrip controls for specific jobs eg Font ToolStrip. What I need to do is stop user and developers from adding or removing controls from my ToolStrips.
Any help will be gratefully accepted Danny
I am designing a series of ToolStrip controls for specific jobs eg Font ToolStrip. What I need to do is stop user and developers from adding or removing controls from my ToolStrips.
Any help will be gratefully accepted Danny
To create such custom
ToolStripyou should perform this steps:ToolStrip.ToolStrip.Itemsproperty in property grid.Here is detailed descriptions about steps:
Create a class and inherit from
ToolStrip.This way you can add some items to your custom toolstrip at designer. To do so, after creating your class open it in design mode (it may take some times to visual studio detect it can open the file in designer). Then go to properties window and using
Itemsproperty add some items. You can also select items from dropdown above properties window and in events tab, handleClickevent and add some logic.Note: After adding items, go to code view and call
InitializeComponent();is constructor.Disable default designer of
ToolStripYou should disable default designer of
ToolStripto prevent changing items at design-time, so users can not use designer versb or design surface to change items. To do so, it's enough to decorate your custom component class with[Designer(typeof(ControlDesigner))]attribute.Hide
Itemsproperty in property grid.You should hide
itemsproperty aslo in property grid to prevent changing items through property grid. To do so, it's enough to overrideItemsproperty and decorate it with[Browsable(false)].