Click here to Skip to main content
15,889,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
what i want to do is disable 2 button when i enter text in the richtextbox but when i highlight the txt the button enable.

here my code so far

if (txtDisplay.Modified == true)
            {
                cutText.Enabled = false;
                copyText.Enabled = false;
            }


hope someone can help
Posted

Assuming by "highlight" you mean you have selected text:
C#
private bool IsSelection = false;

private void richTextBox1_SelectionChanged(object sender, EventArgs e)
{
    IsSelection = richTextBox1.SelectionLength != 0;

    button1.Enabled = IsSelection;
    button2.Enabled = IsSelection;
}
 
Share this answer
 
what i mean by highlight is the user highlights the text.
 
Share this answer
 
anyone this bit is really annoying me as only part i got a problem with
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900