using System;
using System.Drawing;
using System.Windows.Forms;
public class TextBoxTextChanged : Form
{
TextBox txt;
string strOriginal;
public TextBoxTextChanged()
{
Size = new Size(300, 375);
txt = new TextBox();
txt.Parent = this;
txt.Text = "Enter text here.";
txt.Size = new Size(ClientSize.Width - 20, ClientSize.Height - 100);
txt.Location = new Point(10,10);
txt.TextChanged += new System.EventHandler(txt_TextChanged);
txt.Multiline = true;
txt.BorderStyle = BorderStyle.Fixed3D;
txt.ScrollBars = ScrollBars.Vertical;
txt.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
strOriginal = txt.Text;
}
static void Main()
{
Application.Run(new TextBoxTextChanged());
}
private void txt_TextChanged(object sender, EventArgs e)
{
if (strOriginal == txt.Text)
txt.Modified = false;
else
txt.Modified = true;
if (txt.Modified)
MessageBox.Show("changed");
else
MessageBox.Show("no change");
}
}
|