In a section layout, you can load an RTF or an HTML file into the RichTextBox control both at design time and at run time . Following is a step-by-step process that helps you load these files into the RichTextBox control.
These steps assume that you have already added a Section Report (code based) template in a Visual Studio project and have placed a RichTextBox control inside its detail section. See Adding an ActiveReport to a Project for more information.
To write an RTF file to load into a RichTextBox control
Paste into an RTF File
Customer List by Country
Argentina
Austria
Belgium
Brazil
To load an RTF file into the RichTextBox control at design time
To load an RTF file into the RichTextBox control at run time
These steps assume that the RTF file (for example, sample.rtf) to load has been saved in the bin/debug directory of your project.
The following example shows what the code for the method looks like.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Detail1_Format event. |
Copy Code
|
---|---|
Dim streamRTF As New System.IO.FileStream(System.Windows.Forms.Application.StartupPath + "\sample.rtf", System.IO.FileMode.Open) |
To write the code in C#
C# code. Paste INSIDE the detail_Format event. |
Copy Code
|
---|---|
System.IO.FileStream streamRTF = new System.IO.FileStream(System.Windows.Forms.Application.StartupPath + "\\sample.rtf", System.IO.FileMode.Open); |
To write an HTML file to load into a RichTextBox control
HTML code
HTML code. Paste in a NotePad file. |
Copy Code
|
---|---|
<html> <body> <center><h1>Customer List by Country</h1></center> <h1>Argentina</h1> <ul> <li>Rancho grande <li>Océano Atlántico Ltda. <li>Cactus Comidas para llevar </ul> <h1>Austria</h1> <ul> <li>Piccolo und mehr <li>Ernst Handel </ul> <h1>Belgium</h1> <ul> <li>Suprêmes délices <li>Maison Dewey </ul> <h1>Brazil</h1> <ul> <li>Familia Arquibaldo <li>Wellington Improtadora <li>Que Delícia <li>Tradição Hipermercados <li>Ricardo Adocicados <li>Hanari Carnes <li>Queen Cozinha <li>Comércio Mineiro <li>Gourmet Lanchonetes </ul> </body> </html> |
To load an HTML file into the RichTextBox control at design time
To load an HTML file into a RichTextBox control at run time
These steps assume that the HTML file (for example, sample.html) to load has been saved in the bin/debug directory of your project.
The following example shows what the code for the method looks like.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the Detail1_Format event. |
Copy Code
|
---|---|
Dim streamHTML As New System.IO.FileStream(System.Windows.Forms.Application.StartupPath + "\sample.HTML", System.IO.FileMode.Open) |
To write the code in C#
C# code. Paste INSIDE the detail_Format event. |
Copy Code
|
---|---|
System.IO.FileStream streamHTML = new System.IO.FileStream(System.Windows.Forms.Application.StartupPath + "\\sample.html", System.IO.FileMode.Open); this.richTextBox1.Load(streamHTML, RichTextType.Html); |