Similar Threads
1. MultiLine ToolTips in designer- An Answer
VS2003
1) If you don't have one, add a tooltip control to your design canvas.
2) open the properties for the control that gets the tool tip
3) type in all your text in the 'tooltip on tooltip1' property.
The line feeds come later. The property editor has no way to enter
a \n. It doesn't parse and it doesn't accept control characters
escaped or not.
4) Switch from the design view to the form code.
e.g. 'MainFrm.cs' instead of 'MainFrm.cs[Design]'
5) Find the code that creates the control. It will be in the
InitializeComponent() method that you are NOT supposed to edit.
(More about that later)
6) Change the code for the tooltip from:
this.toolTip1.SetToolTip(this.someControl, "Line1Line2");
to:
this.toolTip1.SetToolTip(this.someControl, "Line1\nLine2");
7) Build and run. When the cursor floats over the control, you'll have 2 lines.
Do NOT look at the design page or examine properties.
8) Exit the solution (close it or save it, or open another, or exit VS)
9) Reopen the solution. Examine the properties for the control.
Tooltip on Tooltip 1 will say: "Line1[]Line2", AND
the linefeed will *stay* until you remove it, even if you edit/change
the design or properties.
Not only that, but the non-printable character '[]' that represents the line
feed in the tool tip text will copy and paste.
Explanation:
The InitializeComponent method is in a reserved region like this:
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
....
#endregion
Whenever you are on the design page making changes, that region is
'empty'. Anytime you look at the page that has the code, or compile the
form, the design page generates code representing the current state
of the design and stuffs it in the region.
When and how are not material. The point is that the region is volatile
and will be re-written anytime the design view wants to (changes).
Now, I'm guessing, but it seems that when put away, the *code* is the
persistent backing for the design view of the form. So when you put
away the solution, and reload it, the design view is recreated from
the code. As a result, the tooltip on tooltip 1 text property now
has an embedded line feed character. The trick here, is that by changing
the 'region code' you have changed the persistent image of the form
without the knowledge of the design view.
This is a dirty trick, and I don't know how long it will last, but
it sure beats a stick in the eye. In the meantime, I have a copy/
pastable linefeed character that I can use in any of the properties that
accept text.
regards
bullshark
2. Displaying MultiLine tooltips in CListCtrl anyone?
3. Linecount in multiline textbox
Hi,
In case of an error in an input file, I inform the user which line in the
file (i.e. the string) were the file were encountered.
The user will then need to navigate to this line in the somewhat long text
file shown in a textbos (no word wrap). However he needs to count line
himself!!.
I would like a lable outside the textbox to show the line number on which
the caret is placed.
What event do I need to hook up on if I want to be notified when the caret
has changed, and how do I get the position (then I can count lines to this
pos) of the caret in the string that the textbox shows?
Thanx for your help. Very appreciated.
Jesper.
4. DrawString, multiline string but full width - CSharp/C#
5. ListBox entry with \n (multiline)
Hi everyody,
I want to diplay strings of some objects in a LixtBox.
Sometimes the text is longer than my ListBox and a horizontal scrollbar
is displayed.
Is it possible to get the ListBox to display the Text in multiple lines
(per entry)?
I found some controls on CodeProject but they are to overloaded. I just
want to diplay the Text without scrolling (that every word of the stings
is visible on the first sight).
Greetings
Stefan
6. Multiline TreeNode - CSharp/C#
7. DrawString, multiline string but full width
On Apr 26, 3:29爌m, "Peter Duniho" < XXXX@XXXXX.COM >
wrote:
> On Fri, 25 Apr 2008 21:51:04 -0700, Sin Jeong-hun < XXXX@XXXXX.COM > ?
> wrote:
>
> > It seems like the default behavior of DrawString is trying to keep the
> > whole word if possible. I'd like the string to be drawn in multilines,
> > but filling the entire line width.
> > [...]
> > Is what I'm trying to do achievable with any formatting options or do
> > I have to draw each character manually with my own calculation?
>
> Off the top of my head, I think maybe you want to set the ?
> StringFormat.Trimming property to Character.
>
> If I'm mistaken about that, you may be able to use the TextRenderer class ?
> instead to do your drawing, using the TextFormatFlags.WordBreak flag (or ?
> rather, making sure that flag is _not_ set) to have the text wrapped on ?
> whatever character reaches the very end of the line.
>
> Sorry I'm being so vague...I don't have something right in front of me ?
> that would let me test the code to make sure my recollection is right.
>
> Pete
Thank you for your reply. But, DrawString() with Trimming property set
to Character didn't work. It was the same as when I didn't even set
the Trimming property. Secondly, TextRender.DrawText draws multiline
text if and only if the TextFormatFlag has WordBreak. Setting
WorkBreak gave the same result as when I used DrawString().
8. tooltip - multiline not working - CSharp/C#