Цитата(nmn @ 16.2.2009, 20:22 ) | не знаю что делает этот код у вас, но у меня он размер не меняет, вернее меняет Size становится равным тому что присваивается, но тут же становится прежним (проверить можно подписавшись на событие SizeChanged или ClientSizeChanged) |
Не надо заморачиваться на всяких мелочах. Если тебе сказали поставить авторазмер в false, так поставь. А я вот другой пример написал.
Код | using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data;
namespace ResizeCheckbox { /// <summary> /// Summary description for Form1. /// </summary> public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.CheckBox checkBox1; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null;
public Form1() { // // Required for Windows Form Designer support // InitializeComponent();
// // TODO: Add any constructor code after InitializeComponent call // }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); }
#region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.checkBox1 = new System.Windows.Forms.CheckBox(); this.SuspendLayout(); // // checkBox1 // this.checkBox1.BackColor = System.Drawing.SystemColors.Info; this.checkBox1.Location = new System.Drawing.Point(8, 24); this.checkBox1.Name = "checkBox1"; this.checkBox1.Size = new System.Drawing.Size(88, 24); this.checkBox1.TabIndex = 0; this.checkBox1.Text = "single"; this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(200, 77); this.Controls.Add(this.checkBox1); this.Name = "Form1"; this.Text = "Resize CheckBox"; this.ResumeLayout(false);
} #endregion
/// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.Run(new Form1()); }
private void checkBox1_CheckedChanged(object sender, System.EventArgs e) { if (checkBox1.Checked) { this.checkBox1.Size = new Size (this.checkBox1.Size.Width * 2, this.checkBox1.Size.Height); this.checkBox1.Text = "double"; } else { this.checkBox1.Size = new Size (this.checkBox1.Size.Width / 2, this.checkBox1.Size.Height); this.checkBox1.Text = "single"; } }
} } |
http://www.filehoster.ru/files/cf3165 |