Multiline tooltip problem... shows the \n's

A

Alex

Hi all -


Read here that embedding \n's into the tooltip string during runtime should
yeild multiline tooltips. However, mine is just keeping the \n's in there
and showing it all on one line.

Any idea how I get it to parse the control chars?

I'm doing something like this:

string slabelinfo = "line1\nline2";
toolTip1.SetToolTip(slabel1, slabelinfo );
 
D

Daniel

use this, \r\n:

string slabelinfo = "line1\r\n line2";
toolTip1.SetToolTip(slabel1, slabelinfo );
 
S

Stefan Z Camilleri

Hi all -


Read here that embedding \n's into the tooltip string during runtime
should
yeild multiline tooltips. However, mine is just keeping the \n's in
there
and showing it all on one line.

Any idea how I get it to parse the control chars?

I'm doing something like this:

string slabelinfo = "line1\nline2";
toolTip1.SetToolTip(slabel1, slabelinfo );

Hi

Try also adding a carriage return character \r since the windows way is
really a combination of cr and lf (lf is just for *nix machines)
 
R

rossum

Hi all -


Read here that embedding \n's into the tooltip string during runtime should
yeild multiline tooltips. However, mine is just keeping the \n's in there
and showing it all on one line.

Any idea how I get it to parse the control chars?

I'm doing something like this:

string slabelinfo = "line1\nline2";
toolTip1.SetToolTip(slabel1, slabelinfo );

You may find that Environment.NewLine works better.

rossum
 
A

Alex

Tried the \r\n, but it stayed on one line. Switched the stored proc that
generates the string back to using \n and did a string.replace of \\n with
Environment.Newline and it replaced the \n with \r\n, but does give a
multiline tooltip.

Don't understand what the diff would be, but it works!

Thanks :)
 
H

Hans Kesting

Tried the \r\n, but it stayed on one line. Switched the stored proc that
generates the string back to using \n and did a string.replace of \\n with
Environment.Newline and it replaced the \n with \r\n, but does give a
multiline tooltip.

Don't understand what the diff would be, but it works!

If a stored procedure generated a "\n" it would be a string of two
characters: '\' and 'n'.
If you use this inside a string literal in a C# program (string s =
"1\n2"), then the *real* string would be 3 characters, with the middle
one being a character with code 10. (Note that the debugger, trying to
be helpful, still will display the "\n").

So the "\n" from the stored procedure is just that, while a "\n" inside
C# is an escape-code for the newline character.


Hans Kesting
 
A

Alex

Good to know - thx for the explanation!

I was thinking the tooltip display would parse the string for \n's, but now
I understand what's going on. Just needed the extra step of replacing the
\n's with newlines in the string then.
 

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