Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Does anybody know any software or visual studio plugin , when form maximize resize all controls (label,textbox,panel etc.). i mean, not like anchor or dock but something external from visual studio properties.
i cant use anchor or dock properties bcos many componets in form and i cant place tablelayoutpanel bcos it dont support copy/paste componets... i just want when the form maximize everything there to be bigger!
Posted
Updated 22-May-14 8:24am
v2
Comments
karthik Udhayakumar 22-May-14 14:21pm    
Is there any concrete reason for going after a third party plugin for this requirement? or any blockage?Explain for better answers from the community:
Emin Kokalari 22-May-14 14:24pm    
hello karthy Udhaykumar ... i cant use anchor or dock properties bcos many componets in form and i cant place tablelayoutpanel bcos it dont support copy/paste componets... i just want when the form maximize everything there to be bigger!
Sergey Alexandrovich Kryukov 22-May-14 14:33pm    
Why?! Well, if the controls are windowed controls, you could relatively easily create such code, but why? If controls are not windowed, such as with WPF, there is virtually now a way...
I don't believe someone would seriously write and provide such code as a product, because — why anyone would do that? I even doubt that even you should go in for anything like that.
It would be much better to write you UI in humane manner...
—SA

Echoing other statements here, I'd say this is not the kind of thing you want to do in WinForms.

You haven't mentioned dynamically scaling Font-size: if you are thinking of that, I'd strongly suggest you forget it. Fonts in WinForms are only going to look good at certain distinct point-sizes.

I'd suggest you analyze if you have too many components on one Form, and adapt a strategy for organizing the components into functional groups, and then using something like a TabControl to display them by group. Or, consider using SplitContainers.

You can also try organizing the components into functional groups using Panels, and you can do a lot with anchoring, or docking, Panels.

If you really have to do this, you'll need to use recursion to handle Controls within Controls, and adjust their sizes using a ratio you calculate (the solution by Karthy above only adjusts the size of the top-level Controls on the Form).

Check out WeiFen Luo's DockPanelSuite: [^]; on SourceForge: [^].
 
Share this answer
 
v2
Comments
Emin Kokalari 23-May-14 6:43am    
hello BillWoodruff , i know about docking and anchor ... but i dont ask for this. my question is that i want to scale not to resize the elents if u understand what i mean with my low english :D ... so the problem its not there.. so for example i have a button and i want it to be bigger when form maximize, but not only button but everything in my form, the problem is that i cant use tablelayoutpanel becos controls are placed before and tablelayoutpanel dont support copy/paste , so when i paste my controls there , they misplaced ... i just want to make things bigger when it maximize, i search everywhere but nothing ...
BillWoodruff 23-May-14 7:37am    
Please see my answers to previous QA questions involving dynamic re-sizing; one of them has an outline for a code solution:

http://www.codeproject.com/Answers/696195/Resize-UserControl-And-Its-Child-Controls

There are other comments/solutions I've made about this question which you can find here:

https://www.google.com/search?q=site%3Acodeproject.com+BillWoodruff+resize&rlz=1C1CHMO_thTH526TH526&oq=site%3Acodeproject.com+BillWoodruff+resize&aqs=chrome..69i57j69i58.16401j0j7&sourceid=chrome&es_sm=122&ie=UTF-8

However, I think you are making a mistake by pursing this. If you really want dynamic re-sizing, I suggest you switch to WPF.
Hello Emin,
Try this code and reference

C#
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
 
public class Form1
{
 
		// Current Width
	int CW = this.Width;
		// Current Height
	int CH = this.Height;
		// Initial Width
	int IW = this.Width;
		// Initial Height
	int IH = this.Height;
 

	private void Form1_Resize(object sender, System.EventArgs e)
	{
		double RW =(double) (this.Width - CW) / CW;
		// Ratio change of width
		double RH = (double)(this.Height - CH) / CH;
		// Ratio change of height

		foreach (Control Ctrl in Controls) {
			Ctrl.Width += Convert.ToInt32(Ctrl.Width * RW);
			Ctrl.Height += Convert.ToInt32(Ctrl.Height * RH);
			Ctrl.Left += Convert.ToInt32(Ctrl.Left * RW);
			Ctrl.Top += Convert.ToInt32(Ctrl.Top * RH);
		}
 
		CW = this.Width;
		CH = this.Height;
 
	}
 

	private void Form1_Load(System.Object sender, System.EventArgs e)
	{
		IW = this.Width;
		IH = this.Height;
 
	}
	public Form1()
	{
		Load += Form1_Load;
		Resize += Form1_Resize;
	}
 
}



Reference:Resizing Controls When Resizing Form[^]

All the Best:) Write back if you are stuck up deploying.
 
Share this answer
 
v2
Comments
Emin Kokalari 22-May-14 14:41pm    
i start with :

namespace Libri_i_Shitjes
{
public partial class admin : Form
{
// asdf
}
public admin()
{
InitializeComponent();
}

it says :
Error 1 The name 'CW' does not exist in the current context C:\Users\EAK TEAM\Desktop\Handy MarketVS 2013\Libri i Shitjes\admin.cs 489 47 Handy Market
Emin Kokalari 22-May-14 15:22pm    
hello karthy Udhaykumar, i cant initialize global variable because it says me "this" doesn't exist in current context....
i start with :

namespace Libri_i_Shitjes
{
public partial class admin : Form
{
Emin Kokalari 23-May-14 6:33am    
hello karthy Udhaykumar, i finally execute this code but all the controls get out of main form... everything is misplaced ... what u think ?>
karthik Udhayakumar 23-May-14 19:33pm    
Sorry Emin,Unable to respond earlier got busy..Have you completed it? Did you check the sln given by BillWoodruff?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900