Adding Controls to UserControl / Component in VS Designer
-
Hi, I'm trying to set up a UserControl or Component that consists of a label, which is colored and has Dock set to Top so that it spans the top of the UserControl/Component. Under this is a Panel, dock set to Fill. When I use this, I want controls that I add to it to be placed in the Panel. But I'm running into difficulties: When I try to do this by creating a UserControl, I cannot add Controls to an instance of it in the VS Designer. When I try to do this with a Component(inheriting from the Panel class), I can add to it, but the Controls end up in the top level Panel, not the inner panel. I could get around this by adding to it programatically, using a custom Add method, but I'd really like to be able to use the designer! Maybe the technique I'm using is incorrect? Or maybe I need to add some kind of override for my UserControl/Component's Add method? How do I do this? Thanks for any help you can offer me.
-
Hi, I'm trying to set up a UserControl or Component that consists of a label, which is colored and has Dock set to Top so that it spans the top of the UserControl/Component. Under this is a Panel, dock set to Fill. When I use this, I want controls that I add to it to be placed in the Panel. But I'm running into difficulties: When I try to do this by creating a UserControl, I cannot add Controls to an instance of it in the VS Designer. When I try to do this with a Component(inheriting from the Panel class), I can add to it, but the Controls end up in the top level Panel, not the inner panel. I could get around this by adding to it programatically, using a custom Add method, but I'd really like to be able to use the designer! Maybe the technique I'm using is incorrect? Or maybe I need to add some kind of override for my UserControl/Component's Add method? How do I do this? Thanks for any help you can offer me.
I don't think a user control will allow you to do this. Have you tried making the panel you want to be modifiable public?
----------------------------- In just two days, tomorrow will be yesterday. http://geekswithblogs.net/sdorman