Blanks vs. Nothing in a RichTextBox

E

eBob.com

I have a RichTextBox in which I'd like blanks to appear different from
nothing. Imagine a file which does not fill up the RTB. You can't tell how
many, if any, blanks might follow the last visible, i.e. non-whitespace,
character. I thought that I could set the BackColor of the RTB to LightGray
and then the blanks would show up as white. But instead the characters show
up on a LightGray background and the blanks, of course, show up as LightGray
spaces.

Is there a solution (which does not require a lot of graphics expertise and
code)?

Thanks, Bob
 
A

Andrew Morton

eBob.com said:
I have a RichTextBox in which I'd like blanks to appear different from
nothing. Imagine a file which does not fill up the RTB. You can't
tell how many, if any, blanks might follow the last visible, i.e.
non-whitespace, character. I thought that I could set the BackColor
of the RTB to LightGray and then the blanks would show up as white. But
instead the characters show up on a LightGray background and the
blanks, of course, show up as LightGray spaces.

Is there a solution (which does not require a lot of graphics
expertise and code)?

Put some text like "[End]" at the end?

Andrew
 
R

rowe_newsgroups

I have a RichTextBox in which I'd like blanks to appear different from
nothing.  Imagine a file which does not fill up the RTB.  You can't tell how
many, if any, blanks might follow the last visible, i.e. non-whitespace,
character.  I thought that I could set the BackColor of the RTB to LightGray
and then the blanks would show up as white.  But instead the characters show
up on a LightGray background and the blanks, of course, show up as LightGray
spaces.

Is there a solution (which does not require a lot of graphics expertise and
code)?

Thanks,  Bob

Umm, why are you doing this?

If you are just wanting to get the user to clean up their extra blank
lines then just do it for them. A simple loop with a negitive step
through the lines property should allow you to trim off any blank
lines (not sure if calling Trim on the text will work or not).

Thanks,

Seth Rowe [MVP]
 
E

eBob.com

I have a RichTextBox in which I'd like blanks to appear different from
nothing. Imagine a file which does not fill up the RTB. You can't tell how
many, if any, blanks might follow the last visible, i.e. non-whitespace,
character. I thought that I could set the BackColor of the RTB to
LightGray
and then the blanks would show up as white. But instead the characters
show
up on a LightGray background and the blanks, of course, show up as
LightGray
spaces.

Is there a solution (which does not require a lot of graphics expertise
and
code)?

Thanks, Bob

Umm, why are you doing this?

If you are just wanting to get the user to clean up their extra blank
lines then just do it for them. A simple loop with a negitive step
through the lines property should allow you to trim off any blank
lines (not sure if calling Trim on the text will work or not).

Thanks,

Seth Rowe [MVP]

I'm developing an application to assist me in the construction of regular
expressions. (I know about Expresso and I am a huge fan. But I have some
needs which go beyond its capabilities.) To develop "tight" regular
expressions I'd like to be able to distinguish between one tab character and
a few blanks.

But more generally, isn't the representation of a file in an RTB more
accurate if you can distinguish between character blanks and space where
there is no graphic for some other reason such as a tab character? (The
first program I wrote for Windows, long before .Net, displayed a file in
hexadecimal! That's how you know what's really in a file!)

In fact it was that first program which led me to believe that it would be
easy in .Net to set a background color for a font which was different from
the background color for the RTB. I didn't do exactly that since I wasn't
using an RTB but I did something similar.

If I can bring up another problem which I anticipate with RTBs, I'd like to
highlight all of the strings in a file which match a regular expression.
But it looks to me like an RTB can have only one "Selected" string. So I am
looking for a solution to this problem as well.

Thanks, Bob
 
E

eBob.com

I have a RichTextBox in which I'd like blanks to appear different from
nothing. Imagine a file which does not fill up the RTB. You can't tell how
many, if any, blanks might follow the last visible, i.e. non-whitespace,
character. I thought that I could set the BackColor of the RTB to
LightGray
and then the blanks would show up as white. But instead the characters
show
up on a LightGray background and the blanks, of course, show up as
LightGray
spaces.

Is there a solution (which does not require a lot of graphics expertise
and
code)?

Thanks, Bob

Umm, why are you doing this?

If you are just wanting to get the user to clean up their extra blank
lines then just do it for them. A simple loop with a negitive step
through the lines property should allow you to trim off any blank
lines (not sure if calling Trim on the text will work or not).

Thanks,

Seth Rowe [MVP]

I'm developing an application to assist me in the construction of regular
expressions. (I know about Expresso and I am a huge fan. But I have some
needs which go beyond its capabilities.) To develop "tight" regular
expressions I'd like to be able to distinguish between one tab character and
a few blanks.

But more generally, isn't the representation of a file in an RTB more
accurate if you can distinguish between character blanks and space where
there is no graphic for some other reason such as a tab character? (The
first program I wrote for Windows, long before .Net, displayed a file in
hexadecimal! That's how you know what's really in a file!)

In fact it was that first program which led me to believe that it would be
easy in .Net to set a background color for a font which was different from
the background color for the RTB. I didn't do exactly that since I wasn't
using an RTB but I did something similar.

If I can bring up another problem which I anticipate with RTBs, I'd like to
highlight all of the strings in a file which match a regular expression.
But it looks to me like an RTB can have only one "Selected" string. So I am
looking for a solution to this problem as well.

Thanks, Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top