Winform窗体最大化后,各个控件随着变换相应的大小。 winform 窗体最大化时,里面的控件怎么一起按照比例变大?现在winform 窗体最大化时,控件还是那么小,很丑,看着不协调。谁有没有好的方法? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://blog.csdn.net/slyzly/archive/2010/04/05/5450751.aspx Anchor设置为上下左右都停靠。随着窗体的变化而变化。 可以采用Form_Resize()。这种方法最灵活,思路是窗体变化时,直接重写这个变化函数。public Form1() { InitializeComponent(); int count = this.Controls.Count * 2+2; float[] factor = new float[count]; int i = 0; factor[i++] = Size.Width; factor[i++] = Size.Height; foreach(Control ctrl in this.Controls) { factor[i++] = ctrl.Location.X / (float)Size.Width; factor[i++] = ctrl.Location.Y / (float)Size.Height; ctrl.Tag = ctrl.Size; } Tag = factor; } private void Form1_Resize(object sender, EventArgs e) { float[] scale = (float[])Tag; int i = 2; foreach (Control ctrl in this.Controls) { ctrl.Left = (int)(Size.Width * scale[i++]); ctrl.Top = (int)(Size.Height * scale[i++]); ctrl.Width = (int)(Size.Width / (float)scale[0] * ((Size)ctrl.Tag).Width); ctrl.Height = (int)(Size.Height / (float)scale[1] * ((Size)ctrl.Tag).Height); //每次使用的都是最初始的控件大小,保证准确无误。 } } AnchorDock多使用容器控件。 如何封装控件在dll中 ActiveX控件在网页里的大小 C/S结构 数据上报实现方式问题 泛型和c++的模版有什么差异? 上午的问题解决了,又有新问题了,急!!! 关于跟新dataset进度条的问题? 用dataAdapter+dataSet删除数据库中纪录疑惑 求识别jpg、gif格式的验证码图片详细教程``书名或者网上有的实例代码教程等都可以` 用向导产生的代码。但是新增Access记录时报错 打开数据库的问题 获取电脑中所有软件的最后运行时间~~~~ 求助,C# 捕获组合键代码
设置为上下左右都停靠。随着窗体的变化而变化。
{
InitializeComponent();
int count = this.Controls.Count * 2+2;
float[] factor = new float[count];
int i = 0;
factor[i++] = Size.Width;
factor[i++] = Size.Height;
foreach(Control ctrl in this.Controls)
{
factor[i++] = ctrl.Location.X / (float)Size.Width;
factor[i++] = ctrl.Location.Y / (float)Size.Height;
ctrl.Tag = ctrl.Size;
}
Tag = factor;
} private void Form1_Resize(object sender, EventArgs e)
{
float[] scale = (float[])Tag;
int i = 2; foreach (Control ctrl in this.Controls)
{
ctrl.Left = (int)(Size.Width * scale[i++]);
ctrl.Top = (int)(Size.Height * scale[i++]);
ctrl.Width = (int)(Size.Width / (float)scale[0] * ((Size)ctrl.Tag).Width);
ctrl.Height = (int)(Size.Height / (float)scale[1] * ((Size)ctrl.Tag).Height); //每次使用的都是最初始的控件大小,保证准确无误。
}
}
Dock多使用容器控件。