SuspendLayout()方法的理解

    SuspendLayout()是临时挂起控件的布局逻辑(msdn),它与ResumeLayout()配合使用。我的理解是使用SuspendLayout()让整个窗口停止,等到所有的东西都设置完毕了,然后用ResumeLayout()把所有的东西加到窗口。

    例如,先调用SuspendLayout(),然后添加两个控件,再调用ResumeLayout(),把控件显示到窗口上,有点像BeginUpdate()和EndUpdate()。

    我不知道我的理解对不对?看到的各位如果觉得我的不对,请留言。

  • 8
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
C#.net实现学生成绩管理系统 namespace 学生成绩管理系统 { partial class Formlogin { /// /// 必需的设计器变量。 /// private System.ComponentModel.IContainer components = null; /// /// 清理所有正在使用的资源。 /// /// 如果应释放托管资源,为 true;否则为 false。 protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows 窗体设计器生成的代码 /// /// 设计器支持所需的方法 - 不要 /// 使用代码编辑器修改此方法的内容。 /// private void InitializeComponent() { this.labeluser = new System.Windows.Forms.Label(); this.textBoxuser = new System.Windows.Forms.TextBox(); this.labelcode = new System.Windows.Forms.Label(); this.textBoxcode = new System.Windows.Forms.TextBox(); this.buttonin = new System.Windows.Forms.Button(); this.buttonout = new System.Windows.Forms.Button(); this.SuspendLayout(); // // labeluser // this.labeluser.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.labeluser.Location = new System.Drawing.Point(31, 50); this.labeluser.Name = "labeluser"; this.labeluser.Size = new System.Drawing.Size(55, 26); this.labeluser.TabIndex = 0; this.labeluser.Text = "用户名"; this.labeluser.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // textBoxuser // this.textBoxuser.Location = new System.Drawing.Point(126, 55); this.textBoxuser.Name = "textBoxuser"; this.textBoxuser.Size = new System.Drawing.Size(112, 21); this.textBoxuser.TabIndex = 1; // // labelcode // this.labelcode.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.labelcode.Location = new System.Drawing.Point(31, 124); this.labelcode.Name = "labelcode"; this.labelcode.Size = new System.Drawing.Size(55, 23); this.labelcode.TabIndex = 2; this.labelcode.Text = "密码"; this.labelcode.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // // textBoxcode // this.textBoxcode.Location = new System.Drawing.Point(126, 124); this.textBoxcode.Name = "textBoxcode"; this.textBoxcode.PasswordChar = '*'; this.textBoxcode.Size = new System.Drawing.Size(112, 21); this.textBoxcode.TabIndex = 3; // // buttonin // this.buttonin.Location = new System.Drawing.Point(34, 200); this.buttonin.Name = "buttonin"; this.buttonin.Size = new System.Drawing.Size(75, 23); this.buttonin.TabIndex = 4; this.buttonin.Text = "登陆"; this.buttonin.UseVisualStyleBackColor = true; this.buttonin.Click += new System.EventHandler(this.buttonin_Click); // // buttonout // this.buttonout.Location = new System.Drawing.Point(163, 200); this.buttonout.Name = "buttonout"; this.buttonout.Size = new
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using opc_Library; namespace Files { /// /// Form1 的摘要说明。 /// public class Form1 : System.Windows.Forms.Form { write_log write_log = new write_log(); private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1; private System.Windows.Forms.Button button1; private System.Windows.Forms.RichTextBox richTextBox1; private System.IO.FileSystemWatcher fileSystemWatcher1; private System.Windows.Forms.Button button2; private System.Windows.Forms.Label label2; /// /// 必需的设计器变量。 /// private System.ComponentModel.Container components = null; public Form1() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); // // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // } /// /// 清理所有正在使用的资源。 /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows 窗体设计器生成的代码 /// /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); this.textBox1 = new System.Windows.Forms.TextBox(); this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); this.button1 = new System.Windows.Forms.Button(); this.richTextBox1 = new System.Windows.Forms.RichTextBox(); this.fileSystemWatcher1 = new System.IO.FileSystemWatcher(); this.button2 = new System.Windows.Forms.Button(); this.label2 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.fileSystemWatcher1)).BeginInit(); this.SuspendLayout(); // // label1 // this.label1.Location = new System.Drawing.Point(8, 16); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(120, 16); this.label1.TabIndex = 0; this.label1.Text = "文件夹全路径名: "; // // textBox1 // this.textBox1.Location = new System.Drawing.Point(8, 40); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(320, 21); this.textBox1.TabIndex = 1; this.textBox1.Text = "C:\\"; // // button1 // this.button1.Location = new System.Drawing.Point(232, 8); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(96, 23); this.button1.TabIndex = 2; this.button1.Text = "浏览文件夹"; this.button1.Click += new System.EventHandler(this.button1_Click_1); // // richTextBox1 // this.richTextBox1.Location = new System.Drawing.Point(8, 88); this.richTextBox1.Name = "richTextBox1"; this.richTextBox1.Size = new System.Drawing.Size(320, 136); this.richTextBox1.TabIndex = 3; this.richTextBox1.Text = ""; // // fileSystemWatcher1 // this.fileSystemWatcher1.EnableRaisingEvents = true; this.fileSystemWatcher1.SynchronizingObject = this; this.fileSystemWatcher1.Changed += new System.IO.FileSystemEventHandler(this.fileSystemWatcher1_Changed); this.fileSystemWatcher1.Created += new System.IO.FileSystemEventHandler(this.fileSystemWatcher1_Created); this.fileSystemWatcher1.Deleted += new System.IO.FileSystemEventHandler(this.fileSystemWatcher1_Deleted); this.fileSystemWatcher1.Renamed += new System.IO.RenamedEventHandler(this.fileSystemWatcher1_Renamed); // // button2 // this.button2.Location = new System.Drawing.Point(232, 64); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(96, 23); this.button2.TabIndex = 5; this.button2.Text = "开始监视"; this.button2.Click += new System.EventHandler(this.button2_Click); // // label2 // this.label2.Location = new System.Drawing.Point(8, 72); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(120, 16); this.label2.TabIndex = 4; this.label2.Text = "文件系统变化情况: "; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(336, 230);
数据库的连接,基本的连接方法namespace data { partial class Form1 { /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// 清理所有正在使用的资源。 /// </summary> /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要 /// 使用代码编辑器修改此方法的内容。 /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.button1 = new System.Windows.Forms.Button(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.aaDataSet = new data.aaDataSet(); this.aaDataSetBindingSource = new System.Windows.Forms.BindingSource(this.components); this.Column1 = new System.Windows.Forms.DataGridViewButtonColumn(); this.Column2 = new System.Windows.Forms.DataGridViewButtonColumn(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.aaDataSet)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.aaDataSetBindingSource)).BeginInit(); this.SuspendLayout(); // // button1 // this.button1.Location = new System.Drawing.Point(110, 227); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 0; this.button1.Text = "button1"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // dataGridView1 // this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Column1, this.Column2}); this.dataGridView1.Location = new System.Drawing.Point(32, 12); this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.RowTemplate.Height = 23; this.dataGridView1.Size = new System.Drawing.Size(240, 150); this.dataGridView1.TabIndex = 1; // // aaDataSet // this.aaDataSet.DataSetName = "aaDataSet"; this.aaDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema; // // aaDataSetBindingSource // this.aaDataSetBindingSource.DataSource = this.aaDataSet; this.aaDataSetBindingSource.Position = 0; // // Column1 // this.Column1.HeaderText = "Column1"; this.Column1.Name = "Column1"; // // Column2 // this.Column2.HeaderText = "Column2"; this.Column2.Name = "Column2"; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(284, 262); this.Controls.Add(this.dataGridView1); this.Controls.Add(this.button1); this.Name = "Form1"; this.Text = "Form1"; ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.aaDataSet)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.aaDataSetBindingSource)).EndInit(); this.ResumeLayout(false); } #endregion private System.Windows.Forms.Button button1; private System.Windows.Forms.DataGridView dataGridView1; private System.Windows.Forms.DataGridViewButtonColumn Column1; private System.Windows.Forms.DataGridViewButtonColumn Column2; private aaDataSet aaDataSet; private System.Windows.Forms.BindingSource aaDataSetBindingSource; } }
namespace ServerDemo { partial class ServerDemo { /// /// 必需的设计器变量。 /// private System.ComponentModel.IContainer components = null; /// /// 清理所有正在使用的资源。 /// /// 如果应释放托管资源,为 true;否则为 false。 protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows 窗体设计器生成的代码 /// /// 设计器支持所需的方法 - 不要 /// 使用代码编辑器修改此方法的内容。 /// private void InitializeComponent() { this.lb_ServerInfo = new System.Windows.Forms.ListBox(); this.bn_Resume = new System.Windows.Forms.Button(); this.bn_Stop = new System.Windows.Forms.Button(); this.bn_Start = new System.Windows.Forms.Button(); this.listBox1 = new System.Windows.Forms.ListBox(); this.cmbClient = new System.Windows.Forms.ComboBox(); this.btnSendto = new System.Windows.Forms.Button(); this.labClientCount = new System.Windows.Forms.Label(); this.SuspendLayout(); // // lb_ServerInfo // this.lb_ServerInfo.FormattingEnabled = true; this.lb_ServerInfo.ItemHeight = 12; this.lb_ServerInfo.Location = new System.Drawing.Point(14, 32); this.lb_ServerInfo.Name = "lb_ServerInfo"; this.lb_ServerInfo.Size = new System.Drawing.Size(572, 100); this.lb_ServerInfo.TabIndex = 61; // // bn_Resume // this.bn_Resume.Location = new System.Drawing.Point(174, 3); this.bn_Resume.Name = "bn_Resume"; this.bn_Resume.Size = new System.Drawing.Size(97, 23); this.bn_Resume.Ta

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值