I am writing just the code:
using System.Windows.Forms;
namespace Test01
{
partial class Form1
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
this.textBox1.Location = new System.Drawing.Point(33, 32);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(186, 20);
this.textBox1.TabIndex = 0;
this.textBox1.Text = "Text";
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(38, 65);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(80, 17);
this.checkBox1.TabIndex = 1;
this.checkBox1.Text = "checkBox1";
this.checkBox1.UseVisualStyleBackColor = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(234, 86);
this.Controls.Add(this.checkBox1);
this.Controls.Add(this.textBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();
}
void textBox1_TextChanged(object sender, System.EventArgs e)
{
if (this.checkBox1.Checked)
this.checkBox1.CheckState = CheckState.Unchecked;
else
this.checkBox1.CheckState = CheckState.Checked;
}
#endregion
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.CheckBox checkBox1;
}
}
and
namespace Test01
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
I get windows with a text box ("Text") and a checkbox. When I focus on the text box and click Ctrl Acheckbox toggle state because TextBox.TextChanged and textBox1_TextChanged are done. But I canβt understand why the TextChanged event was raised on Ctrl A?
source
share