this is my customized form by overriding paint event and implemented form features such as moving ,resizing and some new capabilities. i have a problem with this that all of my form area is accessible for example when i set dock property of a control to fill the control will spread on entire form and border will disapear. i wanna to have a separated and not accessible area for border like c# Forms . how can i do it?
tanks for your help
Related
Environment: Visual studio VB or C#
I have some problem about layer of control. My user control has a panel it's set color to be transparent. In main form I create new instant of user control .But a panel of user control is not transparent.
Ok,a background of user control change to same a background of a main form.
but when I use Ctrl.bringToFront()
a panel of user control will cover all of existing control on the form.
Below image, I add user control to main form. MainForm has green panel. all of them is cover by user control.
I try to use a label control. it has a same problem.
According to third image a label should be blue and red color.
What should i do? if my user control is not rectangle. In my user control,I must use panel for combine many control.it' easy for move or resize.
hi is there a way to adjust form size when padding of a certain control is changed? this is ti prevent controls to overlap the when changed the padding on run time is there a way to do it? or property to set? Currently Using Winforms
Better use the layout controls effectively you can avoid the overlapping of controls.
Refer for WPF Container controls and anchoring and docking properties for Win forms
There are controls in Windows Forms that enable automatic layout. When using theese controls, you can change e.g. margin of a button and the layout will be automatically adjusted so that controls do not overlap.
See FlowLayoutPanel and TableLayoutPanel
See this answer: Dock, Anchor and Fluid layouts in Windows Forms Applications
or the second link in Vasi's answer.
When you need a custom behavior, you will have to program it or combine various controls like Dock panels, anchors, fluid and table layouts. Generally those tasks are easier using WPF, in WinForms it is more difficult.
To change the size of the entire Form I think you need to set it explicitly, there is no automatic Form resize feature:
this.Size = new Size(800, 600);
I have a winform MAINFORM , and need to open child forms in this form as shown in the image. The black portion is a panel & would contain a no. of LinkLabels and Treeview with multiple nodes. In the rest of the portion i want to display the child forms when the linklabels on the panel would be clicked.
The child forms should exactly fit into the remaining space i.e. space excluding the space covered by the panel.
Please help me out with the code, how to fit the new form in the left space.
Also, i would like to ask, that, shall i use the panel or is there some other control which could be more efficient or better here.
Also, does the MAINFORM needs to be made an MdiContainer?
Winforms already does this automatically. You don't have to write any code, simply set the Dock property of the panel control to Left in the designer. The darkgray MDI client area automatically shrinks to occupy the remaining space. Any MDI child windows you create won't overlap the panel, they are constrained to the MDI client area.
I'd have a user control interface on the right docked to fill the remaining space, and each time a link is clicked I'd populate the control interface with a specific control designed for that link labels content. That way you can forget about anything MDI related and for me at least, it would be a lot neater.
In a bit more detail, and a bit of a simpler way, basically everytime a link on the left is clicked, you create a user control that displays the relevant content for that link and display it on the right, docked to the main form so it fills the screen.
Then when another link is clicked, this control on the right is removed and the new one loaded. Have a read about creating user controls and see what you think about this method.
Here's a link to get you started: Creating and using Windows Forms Control Library (User Control) in C#.net
To split the form into sections, take a look at the Splitter control
I have a form on which i want to place certain controls. I want them to be positioned on the form according to the form size, that is, far apart when the form is maximised and close when it is smaller in size.
How to do it?
Thanks.
There are two properties on every windows form control Dock and Anchor Using these you could beautifully place controls and test for different sizes of forms. Check these links and do look out for behaviour by playing around with these properties.
Anchor & Dock
Dock Controls
I have a user control that has:
a) a buttons panel at the top (it always has to be visible)
b) a panel with controls that are dynamically added and re-sized at run-time. The controls can be many, so the panel has to be scrollable.
This user control will be hosted in a form, with the following requirements:
a) The initial size of the form will try to fit in maximum part of the dynamic content.
b) On changing the form size, the control has to be re-sized accordingly.
I had played with various anchoring, docking, and auto-sizing and I don't quite get it working in the way I want to. Sometimes, it is the scrolling that messes up, sometimes it is something else.
What combination of anchoring, docking, and auto-sizing of the panels, usercontrol, form should work best to achieve the desired outcome?
I succeeded to meet the requirements. Here is my solution:
The dynamic panel is anchored to the top and the bottom of the control. It does not AutoSize, it manually changes its MaximumSize and PreferredSize after change in the contents.
The form hosts the form using:
cntrl.AutoSize = true;
cntrl.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
cntrl.Dock = System.Windows.Forms.DockStyle.Fill;
The form subscribes to a custom control's event that notifies for the preferredHeight and it changes its own Height accordingly.
I'd go with a table layout panel. You can specify two rows by one column with the exact size for the buttons at the top and fill the rest with the bottom. Then put put either a normal panel or a flowlayoutpanel for the dynamic content in that area.
Without knowing the specifics of your problem I find multiple fill docked split containers with one fixed panel and/or a fixed slider usually creates a really handy resizing experience. You can also collapse panels very effectively too.