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
ToolStrip
you should perform this steps:ToolStrip
.ToolStrip
.Items
property 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
Items
property add some items. You can also select items from dropdown above properties window and in events tab, handleClick
event and add some logic.Note: After adding items, go to code view and call
InitializeComponent();
is constructor.Disable default designer of
ToolStrip
You should disable default designer of
ToolStrip
to 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
Items
property in property grid.You should hide
items
property aslo in property grid to prevent changing items through property grid. To do so, it's enough to overrideItems
property and decorate it with[Browsable(false)]
.