Hi John,
Based on my understanding, you have a UserControl with some controls on it.
You add the UserControl and a ToolTip on a form and set a tool tip text on
ToolTip component for the UserControl. The problem is that when the
application is run, the tool tip window for the UserControl appears only
when the user hovers the mouse on the area of the UserControl that are not
covered by the "sub" controls on it. If I'm off base, please feel free to
let me know.
I performed a test based on your description and did reproduce the problem
on my side. In fact, when we hover the mouse on a sub control on a
UserControl, the UserControl isn't receive the mouse hover related message,
which is why the tool tip window doesn't show at this time.
To solve this problem, I suggest that you subscribe the MouseHover and
MouseLeave events of each sub control on the UserControl and trigger the
MouseHover and MouseLeave event of the UserControl respectively in the
event handlers.
Then in the form that contains the UserControl, subscribe the MouseHover
and MouseLeave event of the UserControl. In the MouseHover event handler of
the UserControl, call the ToolTip.Show method to show the tool tip window
manually. And in the MouseLeave event handler of the UserControl, call the
ToolTip.Hide method to hide the tool tip window.
The following is a sample. The sample UserControl1 has a Label on it. It
requires that you add an instance of the UserControl1 and a ToolTip
component on the Form1.
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
this.label1.MouseHover += new EventHandler(label1_MouseHover);
this.label1.MouseLeave += new EventHandler(label1_MouseLeave);
}
void label1_MouseLeave(object sender, EventArgs e)
{
this.OnMouseLeave(e);
}
void label1_MouseHover(object sender, EventArgs e)
{
this.OnMouseHover(e);
}
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.userControl11.MouseHover += new
EventHandler(userControl11_MouseHover);
this.userControl11.MouseLeave += new
EventHandler(userControl11_MouseLeave);
}
void userControl11_MouseLeave(object sender, EventArgs e)
{
this.toolTip1.Hide(this.userControl11);
}
void userControl11_MouseHover(object sender, EventArgs e)
{
Point clientpt =
this.userControl11.PointToClient(Cursor.Position);
clientpt.Y += 20;
this.toolTip1.Show("user control tool tip
text",this.userControl11,clientpt);
}
}
Hope this helps.
If you have any question, 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.
JT - 24 Jan 2008 05:41 GMT
Thank you Linda. That worked like a charm!

Signature
John
> Hi John,
>
[quoted text clipped - 96 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
JT wrote :
"I have a user control that essentially groups one radio button and two
labels. Almost all of the surface of the user control is taken up by these
three "sub" controls. I would like to have forms that use this control be
able to set a tool tip on one of its labels. When I try to set the tool tip
on the user control itself, the user really has to find those very small
areas of the control that are not covered by "sub" controls. I can achieve
what I want by making the label public tha I want to have invoke the tool
tip. I was wondering if there was a better way? Thanks."
Hi John,
Maybe I am mis-undertanding your problem, but it simple to add aToolTip
control to your UserControl, then create one public method (per object in
the UserControl, and, if you wish, for the UserControl itself) of a form
like this :
// assume your UserControl has a tool-tip control named uc_toolTip
// and a button in the UserControl named btnButton1
public void setButtonToolTip(string newToolTip)
{
uc_toolTip.SetToolTip(btnButton1,newToolTip);
}
This method can be called from the form hosting the UserControl to change
the tip on the button inside the UserControl at run-time.
If you assume the host "knows" the names of the controls in the UserControl
then you could obviously, pass the name of the control along with the new
tool-tip string and have one procedure in the UserControl that would use a
Switch statement of if-else statements to route the incoming new tool-tip
string to the right control.
At the point you wanted the UserControl tooltip ... in your example "covered
up" by sub-controls, to be sure and appear ... just set all the controls to
display the same tool-tip ?
Or you could create Publc properties in the UserControl (perhaps 'set only)
that you could use in the same way.
best, Bill Woodruff
dotScience