WinForms Resizer软件/插件 [英] WinForms Resizer Software/Plugin

查看:59
本文介绍了WinForms Resizer软件/插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当表单最大化调整所有控件(标签,文本框,面板等)时,是否有人知道任何软件或visual studio插件。我的意思是,不像锚或码头,而是外观来自视觉工作室属性。

i不能使用锚点或停靠属性bcos许多组件的形式,我不能放置tablelayoutpanel bcos它不支持复制/粘贴组件..我只想在表单最大化时将所有内容最大化!

解决方案

在这里回应其他语句,我会说这不是你想要的那种在WinForms中做。



你没有提到动态缩放字体大小:如果你想到这一点,我强烈建议你忘掉它。 WinForms中的字体只会在某些不同的点大小上看起来很好。



我建议您分析一个表单上是否有太多组件,并且适应将组件组织成功能组的策略,然后使用TabControl之类的东西按组显示它们。或者,考虑使用SplitContainers。



您也可以尝试使用Panels将组件组织到功能组中,并且您可以通过锚定或对接Panel来做很多事情。 br />


如果你真的必须这样做,你需要使用递归来处理控件中的控件,并使用你计算的比例调整它们的大小(Karthy的解决方案)上面只调整表格上顶级控件的大小。



查看WeiFen Luo的DockPanelSuite:[ ^ ];在SourceForge上:[ ^ ]。


< blockquote>你好Emin,

试试这个代码和参考



 使用 Microsoft.VisualBasic; 
使用系统;
使用 System.Collections;
使用 System.Collections.Generic;
使用 System.Data;
使用 System.Diagnostics;

public class Form1
{

// 当前宽度
int CW = .Width;
// 当前高度
int CH = this .Height;
// 初始宽度
int IW = this .Width;
// 初始高度
int IH = .Height;


private void Form1_Resize( object sender,System.EventArgs e)
{
double RW =( double )( this .Width - CW)/ CW;
// 宽度比率变化
double RH =( double )( this .Height - CH)/ CH;
// 高度比率变化

foreach (控制Ctrl 控件中){
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 = .Width;
CH = .Height;

}


private void Form1_Load(System。 Object sender,System.EventArgs e)
{
IW = this .Width;
IH = .Height;

}
public Form1()
{
Load + = Form1_Load;
调整大小+ = Form1_Resize;
}

}







参考:调整窗体大小时调整控件大小 [ ^ ]



All the Best :)如果你被部署了,请回信。


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!

解决方案

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: [^].


Hello Emin,
Try this code and reference

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.


这篇关于WinForms Resizer软件/插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆