I have typed in the following text in a control derived from Richtextbox
“The world is {beautful}”.
My main intention is to create a link for the word beautful. I can create this using CFE_LINK , but that’s when I select the text.
When I use Select (4,9), the text within the range 4 to 9 gets deleted.
Can someone please help me with what I am missing out?
CODE :
I am creating a User Control, derived from Richtextbox.
I am giving the exact code below; I have not done any color change. I think the Select command sets the selected text to blue by default.
protected override void OnKeyPress(KeyPressEventArgs e)
{
String keypressed = e.KeyChar.ToString();
if(keypressed == "}")
Select(4,9)
base.OnKeyPress(e);
}
At first when I started messing with this, I was puzzled as well. But then it hit me, it’s very possible that your key that’s being pressed is being sent to the textbox to render at KeyUp. Sure enough, when I changed your code to this it worked: