ToniMontana Posted August 9, 2004 Posted August 9, 2004 Here I have a question to all WinForms-experts ;-) In my app I try to realize the concept of having different fixed-size-areas of the main-form-window, say left-area middle- and right-area. In the left and right I want to display buttons, in the middle normal graphics and other machine-infos. To be able to display different content in each area, I designed these contents as usercontrols which fit in the left-area or middle-area and so on. The main-form-windows has a panel for each area, and in these panels I can plug the usercontrols (after creation) during runtime with the call: panelLeft.Controls.Add(usercontrolX) or panelRight.Controls.Add(usercontrolY) and so on. Now my question: Is there a way to do such things without these panels? Because the problem is: Every time I create a new usercontrol (via CreateInstance()), I MUST do the adding to the panel and this HAS TO BE DONE in the class of the main form window. But I want to do it somewhere else, I think this must be possible because I can ask for the reference of the main-form- window-panels via a property. But it doesnt work. It compiles but after adding a panel from outside it will not be shown correctly. Quote Greetings, Toni.
Heiko Posted August 11, 2004 Posted August 11, 2004 Have you evaluated the DockingStyle property ? Controls need not necessarily reside on a panel. You can also place them directly on the form. I would not recommend this. Not at all. Because you will either get your sizing / docking scrambled when you remove / add or you have to work with fixed locations which is crap too. Another solution might be to add a public method .AddControl (location as myApp.myLocationEnumeration, control as control) to the main form. Quote .nerd
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.