怎么使控件的宽度随窗体宽度的变化而变化? 怎么使控件的宽度随窗体宽度的变化而变化? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 点控件,属性, 确保设置Anchor里面有Left和Right private void Form1_Load(object sender, EventArgs e) { this.Tag = this.Width.ToString() + "," + this.Height.ToString(); this.SizeChanged += new EventHandler(Form1_Resize); } private void Form1_Resize(object sender, EventArgs e) { //this.tableLayoutPanel1.Height = this.Height; // this.tableLayoutPanel1.Width = this.Width; //ResizeInit(this); //MessageBox.Show(this.Width.ToString() + "," + this.Height.ToString()); 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)); } }控件随窗体变化变化大小 在form的resize事件里面写不可能每个控件都改动 只有个别几个控件需要改直接写如:TextBox1.Height=this.Height-100;TextBox1.Width=this.Width-200;如此这般 加个splitContainer控件,把你的控件放到里面,设置要变大的控件的Dock属性为Fill,然后将要变大的控件的Anchor属性改为Top, Bottom, Left, Right ;就OK了 问个简单的c#问题 C#2008水晶报表 WinForm下的MDI问题?不管点击多少次,只需要弹一个窗口,谢谢 WinForm中的XML读取,写入,修改,保存的问题。 设置好断点,启动调试后断点消失 在table中的Textbox不能从数据库里读出数据并显示 why 求国外经典教程<<C#大学教程>>的源码 WPF textbox行Style设置 硬盘序列号,如何取得? 检测电脑是否有framework4.5环境的源码 有C++基础是学C#看什么样的书呢。 关于参数传递,高人进,在线等,谢谢!
{
this.Tag = this.Width.ToString() + "," + this.Height.ToString();
this.SizeChanged += new EventHandler(Form1_Resize);
}
private void Form1_Resize(object sender, EventArgs e)
{
//this.tableLayoutPanel1.Height = this.Height;
// this.tableLayoutPanel1.Width = this.Width;
//ResizeInit(this);
//MessageBox.Show(this.Width.ToString() + "," + this.Height.ToString());
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)); } }
控件随窗体变化变化大小
不可能每个控件都改动 只有个别几个控件需要改
直接写
如:
TextBox1.Height=this.Height-100;
TextBox1.Width=this.Width-200;
如此这般