richtextbox

Understanding RTF and edit it with vb.net

淺唱寂寞╮ 提交于 2019-12-11 02:33:59
问题 I have this RichTextbox in my vb.net form and I would like to when a user click a button, for example to embold the selected text, how would I do this. Also, I do NOT want to use the standard vb.net expressions such as RichTextBox1.SelectedText.Font.Bold = True . I want to do something like RichTextbox1.SelectedRTF="[bold]" & RichTextBox1.SelectedRTF & "[/bold]" or whatever RTF looks like. Can I just add the RTF options random places or can a RichTextBox return an error if the text is in

Insert paragraph between text of richtextbox and change font and color of added paragraph

♀尐吖头ヾ 提交于 2019-12-11 02:19:11
问题 my text is in richtextbox : <Parag1 Level="One"> First text of parag1. Second text of parag1. </Parag1> <Parag2 Level="Two"> First text of parag2. Second text of parag2. </Parag2> <Parag3 Level="Footer"> First text of parag3. Second text of parag3. </Parag3> <Parag4 Level="Three"> First text of parag4. Second text of parag4. </Parag4> The font of all tags with level One, Two, Three is Arial, Size = 9, Color = Red Example : <Parag1 Level="One"> Or </Parag4> The font of text between tags with

Indent only in second line in paragraph in rich text box (c#)

ぃ、小莉子 提交于 2019-12-11 01:17:11
问题 How can I make indent only in the second row, to be space under the first word of paragraph. as this: 回答1: If you can read each line into an array, loop through that array, and if index = 1 then add "\t" to the beginning of the line then adding it to the output String. Let's see if I can write up an example. Let's say you already read each line into String[] lines. String[] lines = readFromTextFileLineByLine(); String output = ""; int index = 0; foreach(String line in lines) { if(index==1)

C# RichTextBox colored text

二次信任 提交于 2019-12-10 21:42:43
问题 I've a RichTextBox and I want color text in it. Is there any tag option? I'd like something like this [color:red]nick[/color] some message . Because I need to save it as text and I want on reload have also colored text. Can I do something like this without writing own method? 回答1: You can set color for text in RichTextBox with SelectionColor And if you want to save your rtf as plain text, then you will have to look at rtf format. Example: {\rtf1\ansi\deff0 {\colortbl;\red0\green0\blue0;

RichTextbox SelectionStart returns wrong index

别来无恙 提交于 2019-12-10 20:57:24
问题 I need to show the user, like in notepad.exe, the selection start and length of his text on cursor. Selection length is no problem because Richtextbox supports the Selection Property with Start and End. http://msdn.microsoft.com/en-us/library/system.windows.documents.textpointer.getoffsettoposition.aspx But the startindex of my RichTexbox is always 2 instead of 0 if I set the cursor on first position of the document. If I CLEAR the complete text it is on 0 . But if I press SPACE and then

Two columns in Winforms RichTextBox

送分小仙女□ 提交于 2019-12-10 20:13:38
问题 In C#, I need to be able to at least give the impression of 2 columns in a single RichTextBox. For my purposes, it could look like this: 1+1 2 70*8+5 565 1000000-300000 700000 76-10 66 For each 'question' in the left column, there will be a corresponding answer. The 'obvious' solution is to use tabs like this: SelectionTabs = new int[] { 0, 500 }; (or simply set \deftab to about 3000 in the raw Rtf). This is all well and good, until the left column input ITSELF contains tabs. When this is the

Inconsistent behaviour between in RichTextBox.Select with SubString method

强颜欢笑 提交于 2019-12-10 19:41:06
问题 I am developing a Windows Form application. I use RichTextBox.LoadFile method to load text from a file and highlight some portion of the text. The text in the file contains return characters. Suppose that I want to highlight the highlight . First I find the startIndex and the length of the the highlight part, then use RichTextBox.Select(startIndex, length) and give some color to it. When I use SubString method, I can find the correct text. But when I apply the same value of startIndex and

Broken tables in RichTextBox control (word wrap) [duplicate]

北城以北 提交于 2019-12-10 17:08:33
问题 This question already has an answer here : Closed 6 years ago . Possible Duplicate: Why isn’t the richtextbox displaying this table properly? We are having problems with the Windows.Forms.RichTextBox control in Visual Studio 2008. We are trying to display text supplied as an RTF file by a 3rd party in a windows forms application (.NET 3.5). In this RTF text file there are tables, which contain text that spans multiple lines. The RTF file displays correctly when opened with either WordPad or

Way to obtain the word cursor is on, in WPF RichTextBox Control

一笑奈何 提交于 2019-12-10 16:13:32
问题 I would like to know how I can get the word that current cursor is on, in WPF RichTextBox. I am aware that RichTextBox has Selection Property. However, this only gives me the text that is highlighted in the RichTextBox. Instead I would like to know the word the cursor is on even if the whole word is not highlighted. Any tips are appreciated. Thank you very much. 回答1: Attach this function to an arbitrary RichTextBox, now called testRTB, and see Output window for results: private void testRTB

Disabling Smooth Scrolling on Richtextbox

浪尽此生 提交于 2019-12-10 15:53:43
问题 I have a label which labels the line numbers based on the text on RichTextBox. I have hooked the event of Vscroll to handle the labeling. private void rtbLogicCode_VScroll(object sender, EventArgs e) { Point pt = new Point(0, 1); int firstIndex = rtbLogicCode.GetCharIndexFromPosition(pt); int firstLine = rtbLogicCode.GetLineFromCharIndex(firstIndex); pt.X = ClientRectangle.Width; pt.Y = ClientRectangle.Height; int lastIndex = rtbLogicCode.GetCharIndexFromPosition(pt); int lastLine =