What do I have to do to see the panel with the things inside which is under the second panel in Visual Studio?
I want to change something in panel1 but i cant see any labels and buttons because panel2 cover it. I dont want to change position of panel2 so what i should do?
that border is button1 border. How to see that button which is covered by panel2?
Changing panel2 Visibile doesnt work.
Panel1 is good option to make pages? Maybe groupbox?
I know from the TabControl to see it's content that you have to click on the tab header in the designer, like you would do on the running program.
Maybe that helps.
Related
OK, this is driving me a bit nuts at this point. Time to ask the crowd:
I have a form that consists of: two vertical "halves" created by a SplitContainer. Inside the bottom "half" / SplitContainer panel... I have:
A set of fields/controls for the user to fill out, contained within a panel.
Below that, a panel containing buttons for "submit", "cancel"...and one that's "show/hide". This "show/hide" is intended to show/hide the panel I just described in point 1 above.
What I want to happen is: when the user clicks to "hide" the panel of controls, not only do those controls vanish, but also:
The panel containing the submit, cancel and show/hide buttons moves up (so that we don't have this big blank space where the now-hidden panel once was).
The form resizes itself vertically so as to make up for the now-hidden panel and the fact that we've moved the bottom controls upwards.
I have no problem getting the panel of controls/fields to show/hide. But I can't seem to figure out how to accomplish the other two tasks. I've tried various combinations of AutoSize, AutoSizeMode, and Dock options.
Any suggestions?
If you put all your controls into a FlowLayoutPanel where the children are arranged vertically, then hiding some controls should cause the "lower" controls to move up the page.
You might still need to write some code to resize the form itself once the optional content has been hidden or before it's shown.
I need some part of UI to behave like dock window, but not all. I wonder if that's possible to mix the two. Say, I want 3 datagrids to be fixed in their positions, but I want settings windows to dock on right side or in middle of main window, when mouse hovers on it, it will expand and show all settings, when mouse moves away, the setting window simply collapses. but I do not want the other 3 data grids to move or collapse. I'd like the data grid show up as normal, not like a dock document.
Thanks
Edit
My project uses both WPF and WinForms. So I am looking for solutions for both
Just dock the settings to the right and listen to the MouseEnter and MouseLeave events. Change the width of the settings to zero, or something very small, when MouseLeave, and back to full width on MouseEnter.
Resizing a docked control behaves very nicely.
Windows Forms project, working only in designer (i.e. with mouse, before the compilation). I have a Form and 2 Panels in it. panel1 is docked (option - fill) in form1. panel2 is docked (fill) in form1, too. Also, panel2 is in front of panel1 (the latter is hidden behind the former). My problem is - when I undock panel2 and dock it again - it docks in panel1 (panel1 becomes it's parent) and not in form1. How can I change the parent of the panel2?
The only solution I figured out so far is cutting (ctrl+x) panel2, selecting form1 and then pasting (ctrl+v) panel2, but this, for some reason, removes all connections between panel2 controls and the code (for example clicking the button on panel2 doesn't work anymore although the function handling the event is still there).
Any better ideas?
Cutting controls to the clipboard will sever the event handlers, so best to stay away from cut and paste in the designer.
Since you are using the designer, open the Document Outline panel from the View - Other Windows menu in Visual Studio. Use the Arrow buttons to properly set the parent or the docking order of the controls.
The Document Outline window looks something like this:
Seems people liked my commented answer so I am putting it here as an answer
You can undock panel1, then move panel two out of panel1 onto the Form1 background. I have struggled with this as well. that was always my work around, I too found that cutting and pasting it cause a lot of haedaches. It can also be fixed in code, using the designer file
The panel can't change Parent when you change is dock !!!
Or I not really anderstand your problem.
But... if you want change the parent. Just remove the panel of the list of Control of the Panel and add it on the list of Control of the form.
yourPanel.Controls.Remove(yourOtherPanel);
yourForm.Controls.Add(yourOtherPanel);
yourOtherPanel.Dock = .....;
I have a TabControl. I add tab pages at runtime. On top of tabPage i add User Control at runtime.
Inside user Control i have richtextbox.
So its like TabControl-->TabPage--->UserControl-->RichTextBox & other controls.
I want my richtextbox to completely fill the space when i maximize. I tried Dock property and panel but no luck.
Any help is appreciated.
Thanks.
Not very clear what is your real problem, but just by guessing:
To me it seems that Dock.Fill can not fail in this condition. What can happen, IMHO, is that TabControl doesn't resize, so its children (richtextbox too) do not change their client area size.
In other words
Set Dock.Fill property on your RichText box
Check out TabControl's Dock, or Anchor properties.
Hope this helps.
I'm developing an app for Windows Mobile 5.0 and above, with C# and .NET Compact Framework 2.0 SP2.
I have a WinForm with two panels inside (upperPanel and bottomPanel). I want that upperPanel always fill 2/3 of form's height, and bottomPanel fills 1/3 of form's height. Both panels will fill completly form's width.
I've used this:
upperPanel.Dock = Fill;
bottomPanel.Dock = Bottom;
But upperPanel fills the form completly.
How can I do this? I want, more o less, the same gui on differents form factors and on landscape or protrait mode.
Thank you.
What you need to do is to put the bottom panel on first and set its Dock property to Bottom. Then set the panel's height to be 1/3 of the form's height. Finally, add a second panel and set its Dock property to Fill. The key here is that you want to add the control that will fill the remaining area to be added last. Alternatively, you can play around with the Bring to Front and Send to Back commands in Visual Studio to get the designer to cooperate.
You may also need to hook the OnSizeChanged event for the form and re-set the height of the bottom panel to account for layout changes. It's been a little while since I did compact framework programming, so I'm not sure.
Right click on the upperPanel and select Bring To Front. However, I don't think this will give you the result you want. When you resize, the bottom panel will remain the same height, while the upper panel will stretch to fill the form.
Using your docking settings, with this code might do the trick:
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
this.bottomPanel.Height = Convert.ToInt32((double)this.Height / 3.0);
}
Set both panels to "not anchored". That is: Remove Dock-Value and clear the Anchor property. Then, move the controls so they are sized the way you'd like them to be sized.
After that, upon resizing the form, they should resize relatively.
EDIT
Oops, just tried it and sure it doesn't work. I mixed this up with a solution that automatically keeps controls centered within the window...
Well, I'd guess you then have to create a handler for the form's Resize event and manually align the controls after the form has been resized.
Go to Tools, Other Windows, Document Outline. Find the two panels, and swap the order of them. The control that has DockStyle.Fill has to come first for it to be docked correctly. (or last.. never sure which one it is, but it is one of them :p)
This won't solve the always 1/3 and 2/3 issue though... cause the bottom panel will have a fixed height (unless I am mistaken). I think maybe the TableLayoutPanel supports this though...
Update: As noted in the comments, that panel doesn't exist in the compact framework. So, I suppose the easiest solution to this problem would then try to use the docking, but update the height of the bottom panel whenever the size of the form changes.
If you want this to work perfectly you'll need to add some code to the Resize event of the Form which then specifically works out the relative sizes and places the controls in the correct place after a resize.
If you're not worried about losing precision and the forms aren't going to move much you can avoid this by using some relatively smart anchoring. Essentially you're going to have to select a "grower" (the part of the form that gets bigger, the bigger the form gets). In this scenario I would probably anchor the top part to Top | Left | Right and the bottom part to Top | Left | Right | Bottom. This would mean that the lower part of the form will get bigger if the form is expanded. In most cases this is acceptable. If it isn't use the Resize event and some code.
The easiest way to do this is to nest panels. Just set up panels for top bottom and fill. Then use panels within those panels to do the same. The only issues I've had therein are datagrid resizing, which is always a pain anyway. in that case, you have to use some code to resize the datagrid control on the form resize event.
I would like to add a point to #jasonh answer.
For the panel that occupies 2/3 of the form, you will have to set the AutoScroll property of the panel to true.
This will enable the panel to display scroll when the control size exceed the visibility to the user and also ensure the visibility of the smaller panel which is 1/3 of the forms height.
You can get the required design by using nested panels along with few setting with Anchoring and Docking Properties.Follow the following steps:
1) Add the Form and put a Panel1 on it. Set its Dock Property as 'Fill' and ResizeMode as 'Grow&Shrink'.
2) Add Second panel2 and set its Dock Property to 'Bottom', Set the Height and set the Anchor property to 'Top,Left'.
3)Add Third panel and set its Dock Property to 'None', Set the Height and set the Anchor property to 'Top,Bottom,Left,Right'.
Save and Compile. Now all the panels Would maintain their relative Positioning With resizing.