Hi James,
Sorry for my delayed reply.
The LanguageOption property of RichTextBox is new in .NET 2.0. This
property gets or sets a value that indicates RichTextBox settings for Input
Method Editor (IME) and Asian language support. The default value of the
LanguageOption property of RichTextBox is AutoFont|DualFont. That's to say,
RichTextBox supports DualFont by default.
When a richtextbox supports DualFont, it doesn't means that we could set an
English font for ASCII text and an Asian font for Asian text at one time.
Instead, we should make use of the SelectionFont property of the
richtextbox to set fonts for the two kinds of text respectively.
For example, we could add two buttons called button1 and button2 on the
form. Click button1 to set an English font for ASCII text and click button2
to set an Asian font for Asian text. To set the ASCII text in the
richtextbox to the English font, select the ASCII text in the richtextbox
and click button1. To set the Asian text in the richtextbox to the Asian
font, select the Asian text in the richtextbox and click button2.
If my project has many RichTextBox, can I print these contents in one
paper?
In the sample provided in the Microsoft support website, the actual
printing work is done by the SendMessage Win32 API, which is called in the
Print method in the RichTextBoxPrintCtrl class. This line of code is 'res =
SendMessage(Handle, EM_FORMATRANGE, wparam, lparam);'. Note that the
richtextboxctrl control's Handle is passed to the SendMessage function.
This means that we could only print out the content in ONE richtextboxctrl
control at one time.
To print out the contents in several richtextboxctrls at one time in one
paper, we could copy the contents in all the richtextboxctrls into one
richtextboxctrl and print the total content out and restore the content in
the richtextboxctrl after the printing is finished. Suppose there're two
richtextboxctrls on the form. The following is a sample to print out
contents in both richtextboxctrls at one time.
void printDocument1_BeginPrint(object sender,
System.Drawing.Printing.PrintEventArgs e)
{
this.richTextBoxPrintCtrl2.SelectAll();
this.richTextBoxPrintCtrl2.Copy();
this.richTextBoxPrintCtrl1.Focus();
this.richTextBoxPrintCtrl1.SelectionStart =
this.richTextBoxPrintCtrl2.TextLength;
this.richTextBoxPrintCtrl1.Paste();
checkPrint = 0;
}
void printDocument1_EndPrint(object sender,
System.Drawing.Printing.PrintEventArgs e)
{
this.richTextBoxPrintCtrl1.Undo();
}
how can I set the coordinates of print out paper using RichTextBox? e.g.
adjust to center, adjust 2 cm in left side...
You could make use of the DefaultPageSettings property of PrintDocument to
set the page margin. The following is a sample.
this.printDocument1.DefaultPageSettings.Margins.Left = 200;
Hope this helps.
If you have anything unclear, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support