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.
Related
How can I resize a windows form without hiding controls that are positioned outside the form's new size?
Check out the .Anchor property of the buttons you want to avoid hiding. The anchor property can be set such that the placment of the buttons is alwas relative to one or more edges of the form. This way, when the form is resized, the buttons location is "anchored" to (for example) the Bottom and right edges of the form.
This will not prevent the user from making the form smaller than the minimum space required by the buttons, but I believe you can also set a minimum size property for the form.
set the anchor property of your buttons or items in form.
If still you have issues, put the buttons or controls to pannel or groupbox and dock the buttons to parent container. Then apply anchor property for controller.
I Have found the similar issue and what i tried is to put all the buttons in a TableLayoutPanel and set the Anchor property of the buttons that way i am able to resize the button corresponding to the size of the form.
If any body has a better idea kindly suggest........
how to resize a tab control in a winform (C# .Net), controls(inside tabpage) must move while resizing the form
maybe the Dock property is what you're looking for.
If you put a panel.Dock=Dock.Fill then it will take all the space available.
so when the controls is resized, the panel is too.
Going off of your comment to Andrzej's answer:
the control's size must be unchanged and move one below the other while resizing the form
It sounds like what you need is a FlowLayoutPanel. Drop one onto your TabPage, set its FlowDirection property to the value of your choice, and place your controls into it. Now, whenever the TabControl is resized, the controls it contains will automatically shift positions to fill the space.
Set Anchor property of that control. Alternatively you may use Dock
Anchor - defines a constant space between one or more edges of it's container.
Dock - control borders are docked to its parent control.
I'm not sure what it's called in the land of WinForms, but in web development terms, I'm looking for a frame type element that can be added to a winform.
I want a panel that is anchored top,bottom,left,right but if the form the panel is resized to a smaller size than the elements in the panel, scroll bars will appear around the panel allowing the user to see the contents of the panel without expanding the form.
I hope that makes sense, and that such a thing exists.
Thanks!
Yes, a Panel control. Set AutoScrollMinSize to the minimum size you want before scrollbars appear. Set AutoScroll to True. Set MinimumSize if necessary, it shouldn't be.
The controls inside the panel need to auto layout by themselves so they'll move as necessary when the panel gets smaller. Use their Dock or Anchor properties. If the layout gets complicated then switch to a TableLayoutPanel or FlowLayoutPanel control.
What about a panel? System.Windows.Forms.Panel
You are looking for a "Panel" control. Just set the "Dock" property to get docking going..
You add a Panel to your form and set Panel.Dock = Fill. Your Panel will auto-resize when you resize the form.
Set Panel.AutoScroll = True
Then, you add controls to your Panel. Set the controls' Dock property accordingly. Now, when you resize the form, scrollbars will appear if controls are covered up.
There are a couple of different panels in the standard windows controls that do what you want... just look in the toolbox when editing a windows form, under 'container'
What do you want it to contain? A web page, or just windows form controls?
I am intersted whather I can make controls like treeview, RTF or tabcontrols resizable (I guess I can) and how. I know about using splitters but those only enable to make two areas to "overlap".
Thank you!
You can set the control's Dock property to Fill. This will cause the control to fill it's parent container.
You may still need to write some code to handle laying out the child controls. You can either do this by handling the Resize event, or by using a container that supports resizing for you (such as FlowLayoutPanel or TableLayoutPanel).
The easiest way is to anchor the controls to the container they are in. Then, when the container is resized, the controls will be resized as well. Check out the Anchor property of the controls. You can set the control to anchor to the left, right, top, bottom of the container or any combination of those.
I have a fairly simple user control that represents a basic login control. So it has a couple labels, text boxes, and a button. I would like this user control to fill its container, so I have set its dock mode to fill. So far easy enough.
Now, I would like all the controls in my user control to be centered based on whatever size my user control is when rendered. I can't think of a anchor / dock combination that will do the trick.
The user control has a ReSize event. So I know I can calculate and move the controls based on my User control's size during that event. But I was hoping this issue was common enough to be handled through the designer if I desired.
It is actually all pretty simple. You just have to turn off all anchor properties, and set dock to none.
Look at the TableLayoutPanel control and use it in conjunction with the docking and anchor properties. You should be able to control the layout fairly precisely that way.