none
ToolStripControlHost - How can I use the visual designer? RRS feed

  • Question

  • Hi all,

    I am working with a ToolStripControlHost.  I added a new userControl and changed the class to be based on ToolStripControlHost.  Then I added the base reference to the constructor as required

    But when I changed the declarations and try to open it using the visual designer, I get an error:

     "Constructor on type '....ToolStripControlHost' not found". 

    If I change the class back to UserControl and remove the : base(xxx) reference, I can open it in the visual designer again.

    Does anyone know what I need to change so that I can see it in the visual designer without having to change back to UserControl? 

    (If you are curious, I want to see it in the visual designer as that is the easiest way to add events, see all the properties, etc.)

    This doesn't show in the visual designer:

    	[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.ToolStrip)]
    	public partial class agencyDate : ToolStripControlHost
    	{
    		public agencyDate()
    			: base(new ucDateAgency())
    		{
    			InitializeComponent();
    		}
    

    but this does:

    	public partial class agencyDate :UserControl //: ToolStripControlHost
    	{
    		public AgencyDate()
    			//: base(new ucDateAgency())
    		{
    			InitializeComponent();
    		}
    

    This only afects the visual designer.  It works just fine when I actually run the code.

    Thanks,

    me

     


    me (and yes, I DO mark correct answers)
    Thursday, January 5, 2012 7:02 PM

Answers

  • Hi FletcherJ,
    The ToolStripControlHost does not implement a visual designer because it doesn’t need. ToolStripControlHost only hosts customs controls or Windows Forms control which mean that it don’t have any appearance. If you want to design the appearance, you just need to design the hosted control (ucDateAgency).
    A custom ToolStripControlHost is similar to ToolStripTextBox , which could be add in ToolStrip Control.
    Best Regards,

    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us
    • Marked as answer by FletcherJ Friday, January 6, 2012 5:23 PM
    Friday, January 6, 2012 7:11 AM
    Moderator

All replies

  • this component "ToolStripControlHost" does not implement a visual designer

    Best regards,


    Marvin E. Pineda

      ComboBoxMultiColumns

     NetBarControl

      TextEditor


    Friday, January 6, 2012 1:52 AM
  • Marvin,

    Any idea why not?  It's just a container....  I guess the way MS designed it, it was just too complex to allow us to easily design toolbar controls....

    Thanks,

    me


    me (and yes, I DO mark correct answers)
    Friday, January 6, 2012 5:37 AM
  • Hi FletcherJ,
    The ToolStripControlHost does not implement a visual designer because it doesn’t need. ToolStripControlHost only hosts customs controls or Windows Forms control which mean that it don’t have any appearance. If you want to design the appearance, you just need to design the hosted control (ucDateAgency).
    A custom ToolStripControlHost is similar to ToolStripTextBox , which could be add in ToolStrip Control.
    Best Regards,

    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us
    • Marked as answer by FletcherJ Friday, January 6, 2012 5:23 PM
    Friday, January 6, 2012 7:11 AM
    Moderator
  • Bob,

    The main advantage for having it in a visual designer is that I can use the properties/events window to add code, set properties, etc.  But, as you pointed out, most of the real work is done in the subcontrol anyway. 

    Thanks,

    me


    me (and yes, I DO mark correct answers)
    Friday, January 6, 2012 5:24 PM