111,098
社区成员




public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void splitCheck_CheckedChanged(object sender, EventArgs e)
{
float target = this.splitCheck.Checked ? 10 : 150;
float current = this.splitContainer1.SplitterDistance;
const int frames = 20;
float step = (target - current) / frames;
for (int i = 0; i < frames; i++)
{
current += step;
this.splitContainer1.SplitterDistance = (int)current; //<--
Application.DoEvents();
}
}
}
partial class Form1
{
private void InitializeComponent()
{
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.splitCheck = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Panel1.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.splitContainer1.Panel1.Controls.Add(this.splitCheck);
this.splitContainer1.Panel1MinSize = 10;
this.splitContainer1.Size = new System.Drawing.Size(442, 323);
this.splitContainer1.SplitterDistance = 150;
//
// splitCheck
//
this.splitCheck.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.splitCheck.Appearance = System.Windows.Forms.Appearance.Button;
this.splitCheck.Location = new System.Drawing.Point(138, 85);
this.splitCheck.Size = new System.Drawing.Size(10, 123);
this.splitCheck.UseVisualStyleBackColor = true;
this.splitCheck.CheckedChanged += new System.EventHandler(this.splitCheck_CheckedChanged);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(442, 323);
this.Controls.Add(this.splitContainer1);
this.ResumeLayout(false);
}
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.CheckBox splitCheck;
}