473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

RichText Problems

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!
Dec 28 '07 #1
3 1329
On Fri, 28 Dec 2007 11:54:29 -0800, Soulless <dg*******@gmail.comwrote:
[...]
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??
I'm not seeing anything immediately apparent to me. Maybe someone else
can solve this via code inspection.

But: what do you see when you step through the code? What is the
selection just before you set the selection formatting properties? Did it
get set to the text you expected it to?

Pete
Dec 28 '07 #2
On Dec 28, 2:02*pm, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
On Fri, 28 Dec 2007 11:54:29 -0800, Soulless <dgmsal...@gmail.comwrote:
[...]
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??

I'm not seeing anything immediately apparent to me. *Maybe someone else *
can solve this via code inspection.

But: what do you see when you step through the code? *What is the *
selection just before you set the selection formatting properties? *Did it *
get set to the text you expected it to?

Pete
When I walk through it, it all looks fine... I can see the appropriate
font, but it is not reflected on the Richtext control.

I am putting newlines in as well to work with a totally different line
of text. don't know if that is causing an issue.
Dec 28 '07 #3
On Fri, 28 Dec 2007 12:27:58 -0800, Soulless <dg*******@gmail.comwrote:
When I walk through it, it all looks fine... I can see the appropriate
font, but it is not reflected on the Richtext control.
But what's the selection for the control at the moment that you set the
SelectionFont (for example)?
I am putting newlines in as well to work with a totally different line
of text. don't know if that is causing an issue.
I don't think it should, but I suppose you could try it without them.

For best help, you should post a concise but complete sample of code that
reliably reproduces the problem. I haven't had a chance to try the code
you posted, but if the problem isn't reproducible with any random Forms
application using that code, no one will be able to look at the behavior
directly without a complete sample from you.

Pete
Dec 28 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Pete Griffint | last post by:
Howdy! I want to get the following in a Richtext control: Paragraph 1.... Paragraph 2... Obviously I want to do something like rtb.SelectedText="Paragraph 1...";...
0
by: Lukas Thanei | last post by:
Hi, Im trying for 2 days to solve a problem but now Im on a point where all ideas exhausted. Im writing a software to print out some cards containing richtext and images. To print the...
2
by: Du | last post by:
I like richtext textbox and its shortcut, but I don't need the richtext format. How do I tell the richtext text box to strips all the format and convert everything to plain text? Thanks
4
by: JC - home | last post by:
Hello.. I've been having some problems for a little while with this which I was sure I would beat...hmmm. Anyway, I have a form with two rich textboxes. One at the top which is to display a...
2
by: Gary Shell | last post by:
I have a very ODD situation. I have a RichTextBox and a button. In the button click event I have the following: me.richtextbox1.SelectedText="test" Assuming I start with "aaaabbbbcccc" in...
3
by: rigamonk | last post by:
Is there a way to save richtext from a richtextbox into an access DB using vb.net? thanks patrick
3
by: tlyczko | last post by:
I have Stephen Lebans' RichText control on a subform, which is bound to a memo field. The only editable control on this subform is the rich text control for the memo field. When the main form...
6
by: Tomo | last post by:
How to use RichText in ASP.NET application. I need to make web page where user can write some text, click save and than this content must be saved as html content. Can I find some richtext control...
0
by: giddy | last post by:
hi , i made a little RtfEncapsulator. Its a class thats called RichText , it has an RtfElementCollection which takes any class that exposes the IRtfElement interface. I managed to make an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.