S
Soulless
Hi, I am going crazy trying to resolve a stupid issue. I have a RTB
control and created a method to accept a string and (hopefully) set
the font and size and alignment... Here is the method:
private void AddToRTFReport(string asText, object aoColor,
string asFont,object aoFontStyle, int aiSize, object aoAlignment)
{
int liLen = rtb1.Text.Length;
if (liLen <= 0)
{
rtb1.Text = asText;
rtb1.SelectionStart = 0;
rtb1.SelectionLength = rtb1.Text.Length;
}
else
{
rtb1.Text += asText;
rtb1.SelectionStart = liLen;
rtb1.SelectionLength = asText.Length;
}
rtb1.SelectionColor = (Color)aoColor;
rtb1.SelectionAlignment =
(HorizontalAlignment)aoAlignment;
rtb1.SelectionFont = new Font(asFont, aiSize,
(FontStyle)aoFontStyle);
}
I call my method like this:
AddToRTFReport("Some Text", Color.Black, "Microsoft Sans Serif",
FontStyle.Bold, 10, HorizontalAlignment.Center);
The problem is, if I call it using bold, 16 pt and then call it again
using regular 10 point, everything displays as bold 16pt. It is
making me crazy. Can you see what I may be doing wrong??
Thanks!
control and created a method to accept a string and (hopefully) set
the font and size and alignment... Here is the method:
private void AddToRTFReport(string asText, object aoColor,
string asFont,object aoFontStyle, int aiSize, object aoAlignment)
{
int liLen = rtb1.Text.Length;
if (liLen <= 0)
{
rtb1.Text = asText;
rtb1.SelectionStart = 0;
rtb1.SelectionLength = rtb1.Text.Length;
}
else
{
rtb1.Text += asText;
rtb1.SelectionStart = liLen;
rtb1.SelectionLength = asText.Length;
}
rtb1.SelectionColor = (Color)aoColor;
rtb1.SelectionAlignment =
(HorizontalAlignment)aoAlignment;
rtb1.SelectionFont = new Font(asFont, aiSize,
(FontStyle)aoFontStyle);
}
I call my method like this:
AddToRTFReport("Some Text", Color.Black, "Microsoft Sans Serif",
FontStyle.Bold, 10, HorizontalAlignment.Center);
The problem is, if I call it using bold, 16 pt and then call it again
using regular 10 point, everything displays as bold 16pt. It is
making me crazy. Can you see what I may be doing wrong??
Thanks!