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

  • Thread starter Thread starter Alex
  • Start date Start date
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 );
 
use this, \r\n:

string slabelinfo = "line1\r\n line2";
toolTip1.SetToolTip(slabel1, slabelinfo );
 
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)
 
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
 
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 :)
 
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
 
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.
 
Back
Top