C#WinForm窗体TableLayout控件布局

Winform界面TablLayout是常用的控件之一
可以实现界面任意位置布局,在表格中添加其他控件默认只能占用一个单元格,如果想跨任意数量行列需要使用两个函数设置,下面举例

新建Tab表

在这里插入图片描述

设置插入按钮布局

//
// button1
//
this.tableLayoutPanel1.SetColumnSpan(this.button1, 4);
this.button1.Dock = System.Windows.Forms.DockStyle.Fill;
this.button1.Location = new System.Drawing.Point(3, 3);
this.button1.Name = “button1”;
this.tableLayoutPanel1.SetRowSpan(this.button1, 2);
this.button1.Size = new System.Drawing.Size(394, 84);
this.button1.TabIndex = 0;
this.button1.Text = “button1”;
this.button1.UseVisualStyleBackColor = true;
//
// button2
//
this.button2.Dock = System.Windows.Forms.DockStyle.Fill;
this.button2.Location = new System.Drawing.Point(3, 93);
this.button2.Name = “button2”;
this.tableLayoutPanel1.SetRowSpan(this.button2, 4);
this.button2.Size = new System.Drawing.Size(94, 174);
this.button2.TabIndex = 1;
this.button2.Text = “button2”;
this.button2.UseVisualStyleBackColor = true;
//
// button3
//
this.tableLayoutPanel1.SetColumnSpan(this.button3, 4);
this.button3.Dock = System.Windows.Forms.DockStyle.Fill;
this.button3.Location = new System.Drawing.Point(203, 93);
this.button3.Name = “button3”;
this.button3.Size = new System.Drawing.Size(394, 39);
this.button3.TabIndex = 2;
this.button3.Text = “button3”;
this.button3.UseVisualStyleBackColor = true;
在这里插入图片描述

显示效果

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值