If you have a disabled button on a winform how can you show a tool-tip on mouse-over to inform the user why the button is disabled?
I have since adapted BobbyShaftoe's answer to be a bit more general
Notes:
The MouseMove event must be set on the parent control (a panel in my case)
private void TimeWorks_MouseMove(object sender, MouseEventArgs e)
{
var parent = sender as Control;
if (parent==null)
{
return;
}
var ctrl = parent.GetChildAtPoint(e.Location);
if (ctrl != null && !ctrl.Enabled)
{
if (ctrl.Visible && toolTip1.Tag==null)
{
var tipstring = toolTip1.GetToolTip(ctrl);
toolTip1.Show(tipstring, ctrl, ctrl.Width / 2, ctrl.Height / 2);
toolTip1.Tag = ctrl;
}
}
else
{
ctrl = toolTip1.Tag as Control;
if (ctrl != null)
{
toolTip1.Hide(ctrl);
toolTip1.Tag = null;
}
}
}