[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 931
  • Last Modified:

WinForms and UserControls

Just getting back into WinForms.  All my recent experience is in Web Apps.

I want to load userc controls into my form based on Button or menu item clicks.

Now I KNOW this is a very broad question...

But is the process pretty much the same as in ebApps?

Add a placeholder and load the usercontrols into that?

Any guidance on "best practice" is greatly appreciated.
0
lrbrister
Asked:
lrbrister
2 Solutions
 
CodeCruiserCommented:
Yeah its similar. Just instantiate the control, add it to a container such as form, set its location and you are done.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
For the simplest of cases, you can simply instantiate the controls and add them to your desired container after setting the Location() and/or Size().  Sometimes you may want to increase the size of your container via code as well.

For more complicated scenarios, where you need other existing controls to move around, then you may want to look at using things like the FlowLayoutPanel() or the TableLayoutPanel() which gives you finer control over how controls are laid out with respect to each other.

Another tidbit is to set the AutoScroll() property of a container to True if you want scrollbars to appear automatically on it when controls are out of the visible area.  For example, if you added a series of buttons to a Panel, each one below the previous one, and they exceeded the height of the Panel, then a vertical scrollbar would appear allowing the user to scroll the panel down to the non-visible buttons.
0
 
lrbristerAuthor Commented:
Great. Thanks folks.
Expect more questions to come about seemingly simple things
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now