控件随窗体的大小改变而改变,请各位大侠指点一下,谢谢!急急急急!
解决方案 »
- 【求助】怎么判断某个For循环执行成功,成功则Messagebox提示成功?
- winform中用户控件中textbox的focus问题,求高手!
- C#一个关于图片的问题
- 怎么将TXT的每一列分别写入到不同的txt中
- XAttribute的问题
- 如何达到并行计算(多线程)的是佳性能?
- 菜鸟 求救我的数据库删除效率问题
- (急,100分马上给,参与者有分)Active Document Host的资料
- 指定datagridview的当前选定行
- 学习c#非得学asp.net吗?
- ExecuteNonQuery()和ExecuteScalar()的区别是什么
- 想写一个波形显示控件,没经验,大家帮给点思路。。。先谢啦。。
你要让控件被固定在左上角,this.Control.Anchor=AnchorStyle.left|AnchorStyle.top,这样以来就可以使控件随着窗口沿着右下方变化
判断分辨率
在不同分辨率下调整控件坐标
窗体加载resize时改变坐标
#region 窗体控件同步缩放
protected void BaseAutoScale(Form frm)
{
frm.Tag = frm.Width.ToString() + "," + frm.Height.ToString();
frm.SizeChanged += new EventHandler(frmScreen_SizeChanged);
} protected void frmScreen_SizeChanged(object sender, EventArgs e)
{
string[] tmp = ((Form)sender).Tag.ToString().Split(',');
float width = (float)((Form)sender).Width / (float)Convert.ToInt16(tmp[0]);
float heigth = (float)((Form)sender).Height / (float)Convert.ToInt16(tmp[1]); ((Form)sender).Tag = ((Form)sender).Width.ToString() + "," + ((Form)sender).Height; foreach (Control control in ((Form)sender).Controls)
{
control.Scale(new SizeF(width, heigth));
}
} #endregion