FAQ Database Discussion Community


How can I apply multiple TextDecorations?

wpf,richtextbox
All the examples I've seen for setting Underline, Overline, or Strikethrough all look something like this: // setting underline textRange.ApplyPropertyValue(Inline.TextDecorationsProperty, TextDecorations.Underline); // clearing underline textRange.ApplyPropertyValue(Inline.TextDecorationsProperty, null ); This seems overly simplistic to me; the TextDecorationsProperty returns a collection of decorations - you can have Overline, Underline and Strikethrough all applied...

Regex Split at beginning of line containing word

c#,regex,wpf,richtextbox,flowdocument
I'm trying to split a text into paragraphs each time a line contains a certain word. I already managed to split the text at the beginning of that word, but not at the beginning of the line containing that word. what's the right expression? this is what I have string[]...

RTFLib turns { and } into / [closed]

c#,richtextbox,stringbuilder,brackets,rtflib
I'm not sure if this is widely used as I cannot find much about it online. It's a library that constructs formatted text for a RichTextBox. I've boiled the issue down to StringBuilder though. The RTFLib will find { and } and turn it into //{ and //} to try...

Multiple CheckedChanged event on programmatically added checkboxes

c#,forms,checkbox,richtextbox
I want to be able to assign each checkbox to it's own richtextbox I'm making the richtextboxes, then I'm making the checkboxes but how can I "link" them together? for example : // richtextbox 1 - > checkbox 1 = false // richtextbox 2 - > checkbox 2 = true...

c# richtextbox search with 2 forms

c#,winforms,richtextbox,multiple-forms
I've build an email app in c# winforms with a richtextbox. Now I want to add a search option, which opens in a new Window to enter the search/replace text. I know how to do this in one form, but how do i get access to the richtextbox in form1...

Find and Find Next for RichTextBox

vb6,richtextbox
richTextBox1.Text = "Where there is a will there is way"; I just want to change the both is only red color. I know how to change the first is, but i don't know how to change the second is. RichTextBox1.SelStart = RichTextBox1.Find("is") RichTextBox1.SelLength = 2 RichTextBox1.SelColor = vbRed ...

How do I test what comes after a string

vb.net,find,richtextbox
I need to test what comes after "Text As" in a Rich Text Box. Anyone know how? Private Sub DebugToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles DebugToolStripMenuItem.Click Dim Text_As As String Text_As = RichTextBox1.Find("Text As ") I don't know what to do after that....

Other languages not rendering in Rich Text content control when exporting to PDF using ASPOSE.WORDS for .NET

asp.net,richtextbox,aspose.words
I have some HTML encoded Russian text that have been assigned to a Rich text content control. When exporting the document to .DOC, it exports perfectly displaying the Russian fonts. But, when exporting to .PDF, it exports the Russian fonts as garbage text. Please help. This is the string assigned...

Superscript + Underline inline in a RichTextBox in WPF

c#,wpf,richtextbox,superscript
I have a set of text that I'd like to put in a RichTextBox which goes like so: So I used a RichTextBox since it allows me to do the following. var zipCodeParagraph = new Paragraph(); string zipCodes = String.Empty; var dateRun = new Underline(new Run(DateTime.Today.DayOfWeek + ", " +...

How to get TextRange of text written by user in RichTextBox

c#,wpf,richtextbox,textrange
I have RichTextBox which is like "console". In 'cmd' I displaying data from SSH connection and I also allowing to write something into 'cmd' RichTextBox. public void ConnectTTY() { NewTerminal = new TTY(HostBox.Text, "", LoginBox.Text, PasswordBox.Text); Thread.Sleep(1000); ReadStreamAsync(NewTerminal.reader, cmd); // cmd is my RichTextBox . At first I am filling...

RichTextBox TextChanged not fired

c#,winforms,richtextbox,tabcontrol
I have a RichTextBox which is in a page of my TabControl. Take notice that the RichTextBox is programmaticaly made with the following code: TabPage addedTabPage = new TabPage("Tab Page"); tabControl.TabPages.Add(addedTabPage); RichTextBox addedRichTextBox = new RichTextBox() { Parent = addedTabPage, Dock = DockStyle.Fill, /* ... */ }; Moreover, at the...

RichTextBox prints new line upon receiving a certain character

c#,vb.net,string,textbox,richtextbox
I'd like to know if it is possible for the richtextbox or textbox multi lines to print in a new line upon receiving a certain character like "Z"? Cause I'm having a big time problem in getting values from a richtextbox since last week. It's so hard. My microcontroller is...

How to validate RichTextbox in WPF?

wpf,richtextbox
How to validate RichTextbox in WPF? I want to validate the text for email and email separator i.e. emails should be entered with a semicolon. Xaml: <StackPanel Orientation="Horizontal"> <RichTextBox x:Name="txtEmail" Style="{StaticResource ContentRichTextBox}" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto" Margin="0,0,10,0"> <FlowDocument> <Paragraph LineHeight="5"></Paragraph> </FlowDocument > </RichTextBox> </StackPanel> <StackPanel...

RichTextBox control is only using first formatting

c#,.net,richtextbox,rtf,richtext
I am using Visual Studio 10, .NET Framework 4 and was creating a Rich Text Box Control for Text Input. I am formatting text ONLY by writing the *RichTextBox*.SelectionFont = new Font(currentFontFamily, currentFontSize, currentFontStyle); Method. When I am now accessing the Rtf formatted String via the RichTextBox.Rtf property, it works,...

C# RichTextBox Line-by-line scan

c#,winforms,testing,richtextbox
Hey Im creating my own coding language and I already have the entire application set up with save, open, close, new, etc. In order for the "Run" part to work, I need a way to scan and test every single line in richTextBox1. Maybe for past Java users, something along...

Stop user from typing before generated text

c#,wpf,richtextbox,user-input
I am writing a text editor in WPF (using C#) that simulates a chat program using a RichTextBox. When the user presses enter, the relevant username is automatically inserted on the next line. However, if the user types fast enough, alternating between enter and other key presses, their text can...

Multiple Rich Text Fields on same XPage

xpages,richtextbox
I have an XPage with three Rich Text Fields on it. When the page is in Read Mode the content is separated and shows each field distinctly. However, when the page is put in Edit Mode the three RT Fields get consolidated into what looks like one control containing the...

How do I highlight complete line in a RichTextbox in a C# form

c#,winforms,richtextbox,highlight
After browsing a .txt file I stored each line in an array (i.e. filetext)... String[] filetext = File.ReadAllLines(filepath); How can i highlight particular lines with a color and show them in RichTextBox?...

How to remove a character at the beginning of each line in Richtextbox

c#,winforms,richtextbox
I am creating an app that will remove a certain character for each selected line if you click the button. For example: I have "//" in each line in a RichTextbox and coloured the text into red, it is like the function of comment & uncomment in Visual Studio. The...

RichTextBox : Links with arbitrary text

c#,winforms,richtextbox,dotnetbar
I have a RichTextBox and I wanna append a link inside, with arbitrary text, like this. I found something to make it (http://www.codeproject.com/Articles/9196/Links-with-arbitrary-text-in-a-RichTextBox) but I can't use it because I'm already using DotNetBar's RichTextBoxEx, and I can't replace it. Any ideas ? Thanks in advance....

WPF :: How can I colorize/format HTML?

html,wpf,richtextbox,code-formatting
I have a RichTextBox that is an HTML WYSIWYG editor that saves to HTML; requirements for the project also dictate that we provide an HTML source code editor. What is a good way to go about this? My idea is to load the HTML text directly into a RichTextBox, but...

RichTextBox scroll to end not working when not visible

wpf,wpf-controls,scrollbar,richtextbox,vertical-scrolling
I have a WPF RichTextBox in my application that sits in Grid. It gets updated every second or two as it displays logs (though sometimes there are no logs for up to a minute depending on the load). The grid is not always visible, as it sits in its own...

Change SelectedRTF

c#,winforms,richtextbox,rtf
I have a richTextBox and a Regex with some words. Once, I find all the words I want to change their color to blue. I can use SelectionColor = Blue, but when it comes to coloring thousands of words it becomes quite slow. After some search, I read that changing...

Save RichTextBox Content to Database

vb.net,sql-server-2008,richtextbox
I am trying to save all content of a RichTextBox including images to a VARBINARY(MAX) column in a SQL Server 2008 database. Getting text from the RTB is pretty intuitive, but I have not been able to find where I can get text and images. Is there a property or...

Change color of line containing specified string in RichTextbox

colors,richtextbox,lines
I'm trying to have a RTB show any line containing foo be red. Here's what I've attempted so far: string foo = "foo"; if (richTextBox1.Lines.Contains(foo)) { richTextBox1.Select(richTextBox1.Lines.Contains(foo); richTextBox1.SelectionColor = Color.Red; } Is there a more effective way of going about this or is anyone able to see where I am...

C# RichTextBox + IrrlichtLime -> some keys are not working

c#,richtextbox,irrlicht,lime
I am trying to use a combination of RichTexBox as a input file, which I am passing to Irrlicht engine through my interface. Problem is - when I successfully generate output, most keys on my keyboard are not working in RichTextBox. For example, Enter, Space, keys, Tab, Escape, Backspace are...

InvalidOperationException when I try to delete an image manually from RichTextBox in WPF

c#,xml,wpf,image,richtextbox
I am trying to create an app where I can enter text and images into a RichTextBox, serialize it, then deserialize it and load it back to a RichTextBox so that I can change it later. When I load the images from the serialized xml file, everything displays correctly, but...

Creating control instance in viewmodel

c#,wpf,mvvm,richtextbox,viewmodel
In my program I'm trying to design an output window to display logging information. For right now I'm binding to a string and updating the info as soon as log data comes in. Ex: <FlowDocument> <Paragraph> <Run DataContext="{Binding}" Text="{Binding OutputText}"/> </Paragraph> </FlowDocument> (The flow document is inside a rich textbox)...

EM_SETCUEBANNER doesn't works on RichTextBox

c#,winforms,winapi,richtextbox
I've been using EM_SETCUEBANNER to implement a place-holder on my TextBoxes, it was working fine until I used it on RichTextBox. It doesn't display any text. Here's my code: [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError=true)] public static extern Int32 SendMessage(IntPtr hWnd, int msg, int wParam, [MarshalAs(UnmanagedType.LPWStr)]string lParam); bool SetPlaceHolder(TextBoxBase control, string...

RichTextbox write in place to current line

c#,text,visual-studio-2013,richtextbox
Clarification: I want to output line of text to the same "position" in a RichTextBox, replacing the previous line. In C# Windows Forms Application trying to use RichTextBox for displaying messages. Most of the messages are appended, so that is fine but at one point in the program it has...

Transparent RichTextBox with Graphic not showing Text

c#,winforms,graphics,transparency,richtextbox
I have the following code working, and commented out the Text being drawn onto the control as I started out using this as a graphic only control. Moving on, I have switched the control to be RichTextBox instead of Control so that I can have all the goodies that come...

extract lines from a flowdocument in a richtextbox starting with specific words WPF

c#,wpf,richtextbox,flowdocument
I'm very new to wpf and I would like to make a text analysing tool. I already know how to import text into rich textbox and format it properly, but now I want to run a method that extracts all lines in the flowdocument that start with INT or EXT...

how to add a character at the beginning of each line in Richtextbox

c#,winforms,richtextbox
I am doing an app that adds a certain character for each selected line if you click the button. for example "//" in each line in a Richtextbox and colored the text into red, it is like the function of comment out in visual studio i tried this but it...

Value of a specific line of RichTextBox not changing

c#,winforms,richtextbox
I am trying to do very simple thing which should work but unfortunately its not working. I have a RichTextBox component on my Winform. I am trying to change text value of some lines of the RichTextBox but its not changing the value. Here is my code: private void button1_Click(object...

RichTextBox and special chars c#

c#,special-characters,richtextbox,rtf
I need to put text with RTF format in a richtextbox, I try to put it with the richtextbox.rtf = TextString parameter, but the problem is that the string has special chars and the richtextbox does not show all the string correctly. The String and code that I am using:...

How to use DataReader from Oledb and get results in Richtextbox

visual-studio-2010,richtextbox,datareader,executereader
Dim srch As String srch = ccode.Text conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + IO.Directory.GetCurrentDirectory + "\ptdr.accdb" cmd.Connection = conn conn.Open() Dim dsrch As New OleDbCommand("SELECT pname, page, vdate, psex, summer, bldp, blds, photh, diag, rl, trtmnt, nvdate FROM ptnt_data WHERE pcode = " & srch & "", conn) Dim rdr As...

How do I change the text in a RichTextBox size and removing the highlight on the text?

c#,.net,winforms,richtextbox
This is my code. When I open a text file it's changing the font size of the text but then coloring all the text making it highlight like I select all the text. private void openToolStripMenuItem1_Click(object sender, EventArgs e) { OpenFileDialog theDialog = new OpenFileDialog(); theDialog.Title = "Open Text File";...

Highlight entire line in Richtextbox if a text is present

c#,winforms,richtextbox,highlight
I'm trying to highlight a particular line in my RichTextBox as shown in figure. int ptrsize = 10; int* linenum; for (int i = 0; i < ptrsize; i++) { int value = (linenum[i]) * 10; string searchText = value.ToString(); int indexToText = richTextBox.Find(searchText); int endIndex = searchText.Length; richTextBox.Select(indexToText,...

GetPositionAtOffset() don't return good position

regex,wpf,richtextbox,textrange
I use a RichTextBox in WPF (4.0) and I use the GetPositionAtOffset() method to get a text range between two position in the content in RichTextBox. 1) I initialize the text pointer "position" from MyRichTextBox.Document.ContentStart : TextPointer position = RTBEditor.Document.ContentStart; 2) I get the text from my RichTextBox like that...

C# Enter Timestamp at Enter in Richtexbox

c#,visual-studio,timestamp,return,richtextbox
I am trying to add a timestamp into a richtextbox everytime i hit "enter" on keyboard. The code below partially works, however at Enter a new line is added below my Timestamp. I then have to Backspace to type next to my timestamp. Any suggestions please send. private void richTextBox2_KeyDown(object...