You can dynamycally set the event for all controls in the form, for example:
private ToolTip ToolTip = new ToolTip();
public FormTest()
{
InitializeComponent();
AddMouseHoverEvents(this, true, ShowControlInfo);
ToolTip.ShowAlways = true;
}
private void ShowControlInfo(object sender, EventArgs e)
{
var control = sender as Control;
if ( control == null ) return;
ToolTip.SetToolTip(control, control.Handle.ToString());
}
private void AddMouseHoverEvents(Control control, bool recurse, EventHandler action)
{
if ( !recurse )
Controls.OfType<Control>().ToList().ForEach(item => item.MouseHover += action);
else
foreach ( Control item in control.Controls )
{
item.MouseHover += action;
if ( item.Controls.Count > 0 )
AddMouseHoverEvents(item, recurse, action);
}
}
private void RemoveMouseHoverEvents(Control control, bool recurse, EventHandler action)
{
ToolTip.RemoveAll();
if ( !recurse )
Controls.OfType<Control>().ToList().ForEach(item => item.MouseHover -= action);
else
foreach ( Control item in control.Controls )
{
item.MouseHover -= action;
if ( item.Controls.Count > 0 )
RemoveMouseHoverEvents(item, recurse, action);
}
}
You can show any information you need or show any popup box you want instead of a tooltip.