My C# project contains a form. There are some controls across the top of the form and some controls across the bottom of the form, as well as a FlowLayoutPanel in the center, all of which have been placed with the Visual Studio Form Designer.
During runtime, controls are dynamically added to and removed from the FlowLayoutPanel, and both the panel and the form itself are configured to automatically fit the size of they're contents.
However, since some controls were placed with the designer above and below the FlowLayoutPanel, the desired resizing fails to take place when new controls are added to the FlowLayoutPanel.
Does anybody know of a convenient remedy for this problem?
Anchor the controls you want to move to the side(s) of the form they need to stay the same distance from.
Your best bet might be to put all controls into a 'parent' TableLayoutPanel.
Related
I am browsing an EMGU application built using Windows Forms. The controls in the application are as follows:
I would like to simplify the application down to using fewer image boxes. But when I click on a splitcontainer control, it is selected but I can neither move it around nor even delete it.
How can I break the application down where I can understand what is going on wrt the panels and splitcontainers?
(PS: Not tagging this with EMGU as I don't believe this is an EMGU-specific question.)
I am still not certain about your issue. I give the steps I use to delete SplitContainer from a form:
Right click on the SplitContainer, and choose "Select splitContainerName".
Move its child controls out of it. If its Dock is Fill, set it as none, so you can resize it, and move its child controls to the empty space of the form.
Right click on the SplitContainer, and choose "select splitContainerName" again.
Delete the selected SplitContainer.
So, when I have a form, and I resize it, the controls just get hidden "behind" the form, i guess. I want the controls to resize with the form. How can I do this?
You can use Anchors and Docks. In addition, controls like a TableLayoutPanel can also support you when creating a layout.
see in MSDN Windows Forms Layout
also Dock, Anchor and Fluid layouts in Windows Forms Applications
I am building an app that uses some built in and some 3rd party controls (DevExpress).
Inside the designer, everything looks OK, however while running the app, some controls are placed wrong.
Are there any easy ways to debug this issue?
More specifically, i have a container that holds 2 controls in it.
These controls should stack nicely together one on top of the other (indeed it looks like that in the Designer).
While running the app, one control is displayed on top of the other blocking it (see attached image).
Another weird thing is that some properties of the 2 controls that get overlapped are not updated with respect to their visual status.
this means that a control has a Location of (0, 300) but in fact appears to be in (0, 0).
As a workaround, you could place the two controls in the two panels of a SplitContainer and dock (fill) them there. This has also the advantage that the users can resize the controls.
Another alternative is the TableLayoutPanel.
I'm making a custom GUI for my application. Basically my application has multiple 'tabs'. Each tab has a panel control binded to it, to display tabs contents. Whenever any of the tabs are clicked, appropriate panel control becomes visible (that displays contents) and the rest of the panels become invisible.
The problem is that when I design them in Visual Studio, it's hard to work, ether panels are stacked up on each other or I put them in different coordinates, and when panel becomes active, it's location is updated.
Is there I way I could design all the panels, like on separate 'form' or something like the same way I have separate classes? if that makes sense. Thanks!
EDIT:
I can't use the standard tab control, because my application has custom GUI, all buttons and everything is designed in image processing app. Tab control doesn't allow me to use my own graphics.
I'm going to take a look at UserControl, thanks everybody!
You can create each tab content in a separate UserControl. Use that each UserControl as the only content on each tab.
You should be able to design each "panel" as a separate UserControl.
Your main Form can just be composed from those UserControls, instead of having the entire UI built into one class.
First I would suggest you stick with the standard .NET controls in most cases. Particularly in this case the standard TabControl seems to be a good fit.
That said, you can place all the panels on the form in their final location (being sure not to place a panel within the other panel). You can then use the drop down in the Properties dialog to select the Panel you wish to work with. Next go to the Format menu and choose Order->Bring to Front. This will bring the wanted panel to the front so you may use the designer on it. You can then continue to hide or show the appropriate panels at runtime.
I decided to change a utility I'm working on to use a tabpage. When I tried to drag various controls from the form to a tab page on top of the form, it made copies of the control, giving it a different name. It's easy enough to just remake the form on top of the tab or just edit the source code in the designer to have everything be added to the tab instead (and this is what I did, which worked), but it seems like there would probably be a better way to do this via the gui.
The correct tool for this is the Document Outline (CTRL+W, U). Simply drag your set of controls in the outline so that they are under the tab page. Voila.
The document outline dramatically simplifies these types of operations, especially when you are dealing with complex layouts.
Have you tried cut and paste. That usually works for me.
Your control key is stuck. Do not press control key when dragging controls.
I drag controls from form control to tab page controls all the time no problem. Answer #1 is totally correct.
You can use the Document Outline window and move the controls to the tab page one by one by dragging tree nodes.
The hardest problem is retaining control locations on the tab page.