Y
Yuelin
Hi all
I are stuck on a problem with RichTextBox control. On a simple form - a
label, a richtext control, a button, in the button even method I write:
private void button1_Click(object sender, System.EventArgs e)
{
try
{
string name = this.richTextBox1.SelectionFont.FontFamily.Name;
this.label1.Text = name;
}
catch (Exception ex)
{
Debug.WriteLine (ex.ToString());
}
}
I just simply want to get the font of the text in the rich text box.
I created a short text in Microsoft Word 2000, saved as Rich Text Format,
then I pasted the text into the Rich Text box on the form. When I high-light
the text in the box
and clicked the button, the program throws a exception:
"System.NullReferenceException: Object reference not set to an instance of
an object".
If I create the text in a pain text editor and paste it into the rich text
box, there is no problem.
Is it because Word contains special characters that are not recognised by
the rich text control? But the text created with Word is in RTF format.
I don't know why there is a problem.
Anyone have notice this problem, or know why?
Many thanks
Yuelin
I are stuck on a problem with RichTextBox control. On a simple form - a
label, a richtext control, a button, in the button even method I write:
private void button1_Click(object sender, System.EventArgs e)
{
try
{
string name = this.richTextBox1.SelectionFont.FontFamily.Name;
this.label1.Text = name;
}
catch (Exception ex)
{
Debug.WriteLine (ex.ToString());
}
}
I just simply want to get the font of the text in the rich text box.
I created a short text in Microsoft Word 2000, saved as Rich Text Format,
then I pasted the text into the Rich Text box on the form. When I high-light
the text in the box
and clicked the button, the program throws a exception:
"System.NullReferenceException: Object reference not set to an instance of
an object".
If I create the text in a pain text editor and paste it into the rich text
box, there is no problem.
Is it because Word contains special characters that are not recognised by
the rich text control? But the text created with Word is in RTF format.
I don't know why there is a problem.
Anyone have notice this problem, or know why?
Many thanks
Yuelin