2

I've been looking for the way to change the richtextbox highlight color when a user select text or event mouse move. Windows uses blue as default color.But I want it to be green And blue by default no longer exists.

  private void richIndicateText_MouseMove(object sender, MouseEventArgs e)
    {
        richIndicateText.Select(0, 50);
        richIndicateText.SelectionBackColor = Color.Green;

    }

enter image description here

behnam
  • 1,095
  • 2
  • 11
  • 30

2 Answers2

0
 this.richIndicateText.MouseClick += new MouseEventHandler(richIndicateText_MouseMove); //hook

 this.richIndicateText.MouseClick -= richIndicateText_MouseMove; //unhook

 private void richIndicateText_MouseMove(object sender, MouseEventArgs e)
{
    richIndicateText.Select(0, 50);
    richIndicateText.SelectionBackColor = Color.Green;

}

I will try my best, maybe something like this ?

0

Unfortunately, the desired behavior is not possible in Windows Forms (details here). The workaround would be to use a WPF RichTextBox in the Windows Form through ElementHost.

LP. Gonçalves
  • 454
  • 8
  • 26