fguihen Posted December 21, 2005 Posted December 21, 2005 im adding text to a richTextBox through code. like so: myRichTextBoxEx.SelectedText = "The following is a list of fintans test:"+ "\n" ; i want to be able to set tabs for my text but i cant get it done. heres what ive tried: int[] tabs = {100,300,600,900}; this.myRichTextBoxEx.AcceptsTab = true; this.myRichTextBoxEx.SelectionTabs = tabs; myRichTextBoxEx.SelectionStart = tabs[0]; myRichTextBoxEx.SelectedText = "The following is a list of fintans test:"+ "\n" ; it has absolutely no effect on the position of my text in the text box. actually, when i try to assign tabs[0] to SelectionStart, SelectionStart is always left at 0,no matter how i try to assign a value to it. what am i doing wrong? Quote
Leaders snarfblam Posted December 21, 2005 Leaders Posted December 21, 2005 Tabs are just a formatting tool. You can't treat them like cells in a table (if that is what you are trying to do). When the RTF box encounters a tab character, it advances the location of text output to the next tab. You are setting tab locations correctly, but to use them, you need to insert tab characters (i.e. in the string "Before Tab\tAfter Tab: the "\t" is interpreted as a tab character). If you want to move the cursor to the first tab in the first line of a RTF box, you could do this: char Tab = '\t'; int TabOffset = myRichTextBoxEx.Text.IndexOf(Tab); myRichTextBoxEx.SelectionStart = TabOffset; Quote [sIGPIC]e[/sIGPIC]
fguihen Posted December 22, 2005 Author Posted December 22, 2005 thank you. its been bothering me a while now. thanks for explaining. i was looking at it the wrong way completely. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.