I've implemented a notepad application in c#,all the feaures work perfectly,there is only one thing which I can't implement exactly.there are some menuitems in the edit dropdown menu,but their enabled property must change according to the situation of the textbox,I have a problem with two situations and I'm looking for an event in order to change their enabled property in this event's eventhandler,here is the problem:
2)When some text is selected in the textbox,delete,copy and paste options should get enabled.how should I detect it?I've tested texchanged event an I've written a condition like the code below but it didn't work,just the clipboard works well:
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (textBox1.SelectionLength> 0)
button1.Enabled = false;
if (Clipboard.ContainsText())
button2.Enabled = false;
}
How should I solve my problem,by the way I have to use a textbox not a richtextbox. Any suggestions will be appreciated. Thanks a lot