Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB.Net: Resize Controls when form resizes

Posted on 2012-04-05
3
Medium Priority
?
658 Views
Last Modified: 2012-04-06
Hi Experts,

On my main form, I have got three datagridviews, and they are just drawn during development.

But after I deploying on to many computers that I realized that different screens are not suiting my form. I.E the user wants the datagridview to control to grow when the form is resized big or small when the form is resized small.

To achieve this I had to calculate the distance between the controls size from the form border and then add the distance between in the form resize event. So that depending on the forms size the control  would fit. But it was not easy to deal with multiple controls, because I had to do the same to the rest of the gridview controls.

So is there any other alternative way to accomplish this task.

Thanks in advance.
0
Comment
Question by:baabaa_nl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 668 total points
ID: 37813624
you can use dock property to enable auto-resizing as per the size:-



You can use Dock, or for more precise control use the Anchor property. By setting Anchor to Left, Right, Top, Bottom the control will scale with the window. By setting Anchor to Right the control will move with the right border. By setting Anchor to Top and Bottom the control will scale vertically, but have a fixed width. Just experiment
Reference : http://stackoverflow.com/questions/1636280/automatic-resizing-of-the-windows-forms-controls

http://www.codeguru.com/csharp/csharp/cs_syntax/controls/article.php/c5849/Docking-Control-in-C-That-Can-Be-Dragged-and-Resized.htm
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dock.aspx
0
 
LVL 17

Assisted Solution

by:nepaluz
nepaluz earned 668 total points
ID: 37813684
It depends how you want them laid out.
1.On top of each other - Simply dock each grid to the top of the parent container and set the width to the parent container (and again in the OnResizing event of the parent form)
2. You can place these in a series of split containers which you size to your heart's content
3. More complex is using the tablelayoutpanel. You can set the widths and lengths of each row on your program load (after maximising the form) then et maximum sizes for the datagridviews.

In my experience, the tablelayoutpanel method produces the best results, but needs to be fiddled with to get to grips with it.
0
 
LVL 38

Assisted Solution

by:PaulHews
PaulHews earned 664 total points
ID: 37813687
You really want to use anchor and dock as much as possible to eliminate code from form_resize event.

The  SplitContainer is super useful if you need the user to be able to resize panels at run time.

Other layout controls such as TableLayoutPanelpanel and FlowLayoutPanel can add flexiblity to your layout.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question