Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

  • Leaders
Posted

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;

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...