Hi,
How do I set the 3 tab stop positions within a RichTextBox?
I've been formatting text with a richtextbox control on a windows form. I have the basic format working, fonts, alignment ect... But I have been trying to add tab stops to the formatting. How do I do this. The tabs are inserted in the text, but I am trying to change the spacing between tabs.
Here is a sample of code, I've cut it and changed it from my code but it should give you the basic idea.
{
System.Windows.Forms.RichTextBox rtext;
string print_detail = null;
Font currFont = rtext.SelectionFont;
FontStyle newFontStyle;
float newFontsize;
// New Format
newFontStyle = FontStyle.Regular;
newFontsize = 8;
rtext.SelectionFont = new Font(currFont.FontFamily,newFontsize,newFontStyle);
rtext.SelectionIndent = 100;
// Fills in the string
print_detail = "Table name \t Table Owner \t Table Desc \t Other ";
if (print_detail != null)
{
rtext.AppendText(print_detail);
rtext.AppendText("\n\n");
}
}
I've been trying to use the RichTextBox.SelectionTabs but each time I try to assign the tab stops using this, it crashes at runtime.
int[] tabstops = {100,150,200};
rtext.SelectionTabs = tabstops;
Thanks for any help in advance
MJ
How do I set the 3 tab stop positions within a RichTextBox?
I've been formatting text with a richtextbox control on a windows form. I have the basic format working, fonts, alignment ect... But I have been trying to add tab stops to the formatting. How do I do this. The tabs are inserted in the text, but I am trying to change the spacing between tabs.
Here is a sample of code, I've cut it and changed it from my code but it should give you the basic idea.
{
System.Windows.Forms.RichTextBox rtext;
string print_detail = null;
Font currFont = rtext.SelectionFont;
FontStyle newFontStyle;
float newFontsize;
// New Format
newFontStyle = FontStyle.Regular;
newFontsize = 8;
rtext.SelectionFont = new Font(currFont.FontFamily,newFontsize,newFontStyle);
rtext.SelectionIndent = 100;
// Fills in the string
print_detail = "Table name \t Table Owner \t Table Desc \t Other ";
if (print_detail != null)
{
rtext.AppendText(print_detail);
rtext.AppendText("\n\n");
}
}
I've been trying to use the RichTextBox.SelectionTabs but each time I try to assign the tab stops using this, it crashes at runtime.
int[] tabstops = {100,150,200};
rtext.SelectionTabs = tabstops;
Thanks for any help in advance
MJ