Reputation: 259
I have a richtextbox control, when i load the *.rtf file using a OpenFileDialog to display the contents of that file into richtextbox,it should come in the correct format as in the rtf file(correct format means spaces,font size,word wraping,color etc..) i just want to know how to format the richtextbox..? (or) is there any other way to do it..?
Upvotes: 0
Views: 1144
Reputation: 11
Try to format ALL text in RTB :) Try to use format like bolds, italics, etc in various fragments of text :) Examples like the above are used to circumvent the troublesome issues and hide author's ignorance (in this case - ignorance of MSDN article author).
Upvotes: 1
Reputation: 6968
Maybe this link could help you.
http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.aspx
public void CreateMyRichTextBox()
{
RichTextBox richTextBox1 = new RichTextBox();
richTextBox1.Dock = DockStyle.Fill;
richTextBox1.LoadFile("C:\\MyDocument.rtf");
richTextBox1.Find("Text", RichTextBoxFinds.MatchCase);
richTextBox1.SelectionFont = new Font("Verdana", 12, FontStyle.Bold);
richTextBox1.SelectionColor = Color.Red;
richTextBox1.SaveFile("C:\\MyDocument.rtf", RichTextBoxStreamType.RichText);
this.Controls.Add(richTextBox1);
}
Upvotes: 1