richtextbox

automatic replacement of text in wpf richtextbox

风格不统一 提交于 2019-12-07 08:08:58
问题 I have a WPF .NET 4 C# RichTextBox and I'm wanting to replace certain characters within that text box with other characters, this is to happen on the KeyUp event. What I'm trying to achieve is replace acronyms with full words, e.g.: pc = personal computer sc = starcraft etc... I've looked a few similar threads, but anything I've found hasn't been successful in my scenario. Ultimately, I'd like to be able to do this with a list of acronyms. However, I'm having issues with even replacing a

How to implement basic syntax highlighting in Winforms RichTextBox?

ε祈祈猫儿з 提交于 2019-12-07 06:10:53
问题 I have a list of words I want to highlight in my RichTextBox control, I have an idea on how to do it but having a problem with parsing everything to separate words. How can I parse a line or the whole text into separate words and then enumerate over them and color them using RichTextBox.Select() method. Is this a good way? Is there a better/faster way? 回答1: Use the RichTextBox.Find(String, Int32, Int32, RichTextBoxFinds) method to find your strings in the control. You can then iterate by

RichTextBox (.NET Winforms) problem (or alternative)

做~自己de王妃 提交于 2019-12-07 04:46:41
问题 I have a problem with .Net's RichTextBox control. It seems that it doesn't support table cell formatting, which is funny because most of the time I create tables I want the cell contents to be right-aligned (numbers, currency). If I try to open a WordPad document in RichTextBox, it ignores (and actually removes ) the commands for cell alignment. I tried several workarounds but didn't succeed. Can anyone think of an idea to fix this? (without using fixed-width fonts and spaces) This would be

GetPositionAtOffset equivalent for text only?

倾然丶 夕夏残阳落幕 提交于 2019-12-07 04:00:56
问题 Is there a pretty solution of a GetPositionAtOffset() equivalent which only counts text insertion positions instead of all symbols? Motivation example in C#: TextRange GetRange(RichTextBox rtb, int startIndex, int length) { TextPointer startPointer = rtb.Document.ContentStart.GetPositionAtOffset(startIndex); TextPointer endPointer = startPointer.GetPositionAtOffset(length); return new TextRange(startPointer, endPointer); } Edit: Until now i "solved" it this way public static TextPointer

superscripts are not coming in wpf richtext box

不打扰是莪最后的温柔 提交于 2019-12-07 03:32:39
问题 I have implemented a custom rich text box in a wpf mvvm application and have given option to format the entered text like this: <Button Style="{StaticResource formatTextStyle}" Command="EditingCommands.ToggleBold" ToolTip="Bold"> <TextBlock FontWeight="Bold">B</TextBlock> </Button> I am using EditingCommands.ToggleBold to make the text bold. In the same way I am giving the option for ToggleSuperscript <Button Style="{StaticResource formatImageStyle}" Command="EditingCommands.ToggleSuperscript

How to add a bold text in Rich TextBox programatically using VB.NET

隐身守侯 提交于 2019-12-07 02:18:27
问题 I have this code: print_text.Text = "Patient number: " + ds.Tables("patients").Rows(0).Item(0) print_text.AppendText(Environment.NewLine) print_text.Text = print_text.Text + "Last name: " + ds.Tables("patients").Rows(0).Item(1) print_text.AppendText(Environment.NewLine) Now the above data i am adding programatically and it works fine. However in the above code i want to add Patient number and Last name in bold font. 回答1: When using a RichTextBox , why not just use RTF? Example: Sub Main Dim f

Adding text in a new line in WPF RichTextBox at runtime

邮差的信 提交于 2019-12-07 00:19:38
问题 I want to add some text in a WPF RichTextBox at runtime in a new line. I can do this using: FlowDocument mcFlowDoc = new FlowDocument(); mcFlowDoc = richTextBox.Document; Paragraph pr = new Paragraph(); pr.Inlines.Add(status); mcFlowDoc.Blocks.Add(pr); StatusText.Document = mcFlowDoc; But there is too much of a gap between two lines. How can I fix this? 回答1: According to the documentation, Paragraph spacing is defined by margins, which do not accumulate (no doubling up), so Julien Lebosquain

Set a selection of text to bold inside a RichTextBox

大憨熊 提交于 2019-12-06 21:57:34
In an MS-Access RichTextBox on a Report, I want to make a selection of the text bold. I found this post on a forum which explains how to do this in VB6. I tried the same in MS-Access, both with a normal Access textbox with the Text Format property set to Rich Text and a Microsoft Forms 2.0 TextBox added via the ActiveX Controls dialogue box, neither works. I know VBA is based heavily on VB6 so my logic is if it can be done in VB6, I should be able to do it in Access. Am I right? Is it possible to set a selection of text to bold inside a RichTextBox on MS-Access? You do not mention the version

Show ToolTip on RichTextBox

白昼怎懂夜的黑 提交于 2019-12-06 15:07:44
问题 I have a RichTextBox on a WPF Window. Now, I want to show a ToolTip when the user move the mouse over the RichTextBox. The Content of the RichTextBox should depend on the Text which is under the mouse pointer. For this I should get the position of the char, on which the mouse shows to. Best Regards, Thomas 回答1: In the following example the tooltip will show the next character where the caret is. Xaml: <Window x:Class="Test.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml

Creating custom RichTextBox control

喜欢而已 提交于 2019-12-06 14:18:35
I believe am in need of creating custom RichTextBox in C#. One kind of like that: I admit it might not even have to be RichTextBox , but after some research I decided it's gonna be the easiest way. Functionality I need are icons at each row, checkboxes and text formatting. My program will process each line of the text and mark lines that are correct, incorrect, and strike out lines not necessary in further work, while showing line that's currently processed and allowing user to edit some lines freely (here: lines before Around 3 000 won't be editable, but those under the line will). What's the