RE: Custom ToolTip on ToolStrip
- From: v-lliu@xxxxxxxxxxxxxxxxxxxx (Linda Liu [MSFT])
- Date: Fri, 17 Nov 2006 03:44:00 GMT
Hi Peter,
Based on my understanding, you'd like to use your own ToolTip component to
display tooltip on a ToolStrip control. If I have any misunderstanding,
please feel free to correct me.
I am sorry that I don't think we have a chance to replace the default
ToolTip component associated to a ToolStrip control with a custom ToolTip
component, because ToolStrip class doesn't expose a property for the
default ToolTip it uses.
But I think we could accomplish what you want by other means.
Firstly, set the ShowItemToolTips property of the ToolStrip control to
false.
Secondly, add two methods in your form's code to show and hide tooltip
using the custom ToolTip component. The following is a sample. It assumes
that the ToolStrip's name is toolStrip1, which contains two items called
toolStripButton1 and toolStripButton2 and that the custom ToolTip's name is
toolTip1.
private void toolStripItem_MouseHover(object sender, EventArgs e)
{
ToolStripItem item = sender as ToolStripItem;
switch (item.Name)
{
case "toolStripButton1":
this.toolTip1.Show(this.toolStripButton1.ToolTipText,
this.toolStrip1, this.toolStripButton1.Bounds.Left +
this.toolStripButton1.Bounds.Width/2, this.toolStripButton1.Bounds.Height);
break;
case "toolStripButton2":
this.toolTip1.Show(this.toolStripButton2.ToolTipText,
this.toolStrip1,
this.toolStripButton2.Bounds.Left+this.toolStripButton2.Bounds.Width/2,
this.toolStripButton2.Bounds.Height);
break;
}
}
private void toolStripItem_MouseLeave(object sender, EventArgs e)
{
this.toolTip1.Hide(this.toolStrip1);
}
Thirdly, associate the method "toolStripItem_MouseHover" with the
MouseHover event of each item in the ToolStrip control. Associated the
method "toolStripItem_MouseLeave" with the MouseLeave event of each item in
the ToolStrip control.
Build the project and run it. When you rest the pointer on the ToolStrip,
you should see your custom ToolTip shows tooltip.
Please try my suggestion and tell me the result.
If my suggestion is not appropriate to your scenario, please feel free to
let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
.
- Follow-Ups:
- Re: Custom ToolTip on ToolStrip
- From: Peter Larsen []
- Re: Custom ToolTip on ToolStrip
- References:
- Custom ToolTip on ToolStrip
- From: Peter Larsen []
- Custom ToolTip on ToolStrip
- Prev by Date: Custom ToolTip on ToolStrip
- Next by Date: How can I develep a drop-down control???
- Previous by thread: Custom ToolTip on ToolStrip
- Next by thread: Re: Custom ToolTip on ToolStrip
- Index(es):