change color of row in richtextbox by changing tabindex in c# with wpf

Samed ÇETİN 1 Reputation point
2022-10-14T14:44:56.367+00:00

I'm converting the project I've done with winform before to wpf. But I have some problems.

I paint the lines I want of the text in the richtextbox.

winform code in below,

250573-richtextbox.png

private void TextBoxGcode_TabIndexChanged(object sender, EventArgs e)  
    {  
        if (0 < GcodeSayi)  
        {  
            TextBoxGcode.Find(lines[GcodeSayi - 1], RichTextBoxFinds.MatchCase);  
            TextBoxGcode.SelectionBackColor = Color.White;  
            TextBoxGcode.Find(lines[GcodeSayi], RichTextBoxFinds.MatchCase);  
            TextBoxGcode.SelectionBackColor = Color.DodgerBlue;  
        }  
        else  
        {  
            TextBoxGcode.SelectAll();  
            TextBoxGcode.SelectionBackColor = Color.White;  
  
        }  
  
    }  

TextBoxGcode.TabIndex = TempGcodeSayi;

it could be like this. Changing the color of the relevant line in the richtextbox with the line number I entered from a textbox. I need only line

How can I do it with WPF? Please help.

Thanks,

Developer technologies Windows Presentation Foundation
{count} votes

1 answer

Sort by: Most helpful
  1. Rajanikant Hawaldar 91 Reputation points
    2022-10-17T06:50:48.377+00:00

    painting the selected row will fix this.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.