C#/WPF: Disable Text-Wrap of RichTextBox

前端 未结 6 1560
醉酒成梦
醉酒成梦 2020-12-01 20:44

Does anyone know how I can disable the text wrapping of a RichTextBox? E.g. if I have a large string which doesn\'t fit in the window, the RichTextBox

6条回答
  •  时光说笑
    2020-12-01 21:32

    Suitable solution for me. The idea was taken from here. I defined in XAML

                
                    
                        
                            
                                
                                
                            
                        
                    
                
    

    In Code

       private void MyRichTextBox_OnTextChanged(object sender, TextChangedEventArgs e)
        {
            double i  = PART_rtb.Document.GetFormattedText().WidthIncludingTrailingWhitespace + 20;
            (sender as RichTextBox).Document.PageWidth = i;
        }
    

提交回复
热议问题