Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Able to type only when I click in rich text box, wpf c#?

$
0
0

Hi

I am developing a computer application in which user can able to type inside rich text box. I have provided the feature, when user types, the text will be left aligned which is normal alignment. But when the user presses tab key, the text should be center alignment.

The problem  is, when the user presses tab key, cursor moves to center of the page but doesnot blink. Seems like it gets freeze. Cant able to type anything. Then if, user clicks inside the rich text box, then user can able to type with text center alignment.

private void richTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (comboBox.SelectedIndex == 1)
            {
                richTextBox.Selection.ApplyPropertyValue(Paragraph.TextAlignmentProperty, TextAlignment.Center);


            }
private void text_pressed(object sender, KeyEventArgs ke){
if (ke.Key == Key.Tab)
                {
                    comboBox.SelectedIndex = 1;
                this.Focus();
                }
}


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>