1 public partial class UserControl1 : UserControl 2 { 3 public UserControl1() 4 { 5 InitializeComponent(); 6 this.tableLayoutPanel1.ColumnStyles[1].Width = 0; 7 } 8 //显示 9 private void toolStripButton1_Click(object sender, EventArgs e) 10 { 11 this.tableLayoutPanel1.ColumnStyles[1].Width = this.tableLayoutPanel1.ColumnStyles[0].Width; 12 this.Refresh(); 13 } 14 //隐藏 15 private void toolStripDropDownButton1_Click(object sender, EventArgs e) 16 { 17 this.tableLayoutPanel1.ColumnStyles[1].Width = 0; 18 19 } 20 }
this.tableLayoutPanel1.ColumnStyles[1] 为第二列 , 0为第一列