Click here to Skip to main content
15,886,823 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When i open design view when my control is derived from UserControl i am able to add controls and position them just like i would with a form. if i derive from a existing system control design view displays the message "To add components to you class, drag them from the Toolbox and use the Properties window to set their properties. To create methods and events for you class, click here to switch to code view". If I add a control to this editor it appears as an icon and text. I cant position it over the control. What i am trying to do is derive a control from a ToolStrip and be able to add and edit toolstripitems in the viewer. Is this possible
Posted
Updated 30-May-11 20:47pm
v2
Comments
Sergey Alexandrovich Kryukov 30-May-11 12:00pm    
Always tag it! Add the tag "Forms". Rename the title to something like "Subclassing Control class".
--SA
Sergey Alexandrovich Kryukov 30-May-11 12:01pm    
Not clear: what would be the new functionality of your derived ToolStrip class? This is possible of course, not sure about what you want to achieve and why.
--SA
viciouskinid 31-May-11 2:52am    
I have my own custom control that i use for vector drawing. This control is loaded in my main form and i have a toolstrip that communicates with it. I want to try to neaten up my main form code by moving the code for my tool strip to my new Toolstrip class. It isnt necessary to have the full design view but i would like it. I also think It would be useful for other things in the future.

1 solution

Hi,

I believe the problem you are having with using a derivation of the ToolStrip control in the component designer, is that the 'Controls' collection is not the correct container in a ToolStrip, (you add ToolStripItems to the Items collection in the ToolStrip, not the Controls collection like other controls)

There is a sort of compromise: view the properties of your custom-control in the designer, find the Items collection property, and click the button with three dots in it [...]

This opens the Items Collection Editor, and allows you to visually add ToolStripButtons, ToolStripLabels, ToolStripDropDownItems etc to the ToolStrip control, - they won't however appear visually on the designer canvas.

Hope this helps.

Cheers,

Simon.
 
Share this answer
 
Comments
viciouskinid 31-May-11 4:22am    
Thanks Simon

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900