Reputation: 701
in my application i want to add Tool-tips. after configure the tool tip i want the option to distinguished between the label who activate the Tool tip in order to show the appropriate text so in the Tool tip function i am try to do it but got an error: "The type 'Accessibility.IAccessible' is defined in an assembly that is not referenced. You must add a reference to assembly 'Accessibility, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
private void toolTip1_Popup(object sender, PopupEventArgs e)
{
string st = e.AssociatedControl.AccessibilityObject.Parent.Name;
}
Upvotes: 0
Views: 925
Reputation: 5380
You don't need to reference the AccessibleObject. All you need is get the name of the AssociatedControl, like so:
private void toolTip1_Popup(object sender, PopupEventArgs e)
{
string st = e.AssociatedControl.Name;
}
As for your subquestion, to set the tooltip text dinamically you could try something like this:
private bool recursing;
private void toolTip1_Popup(object sender, PopupEventArgs e)
{
Control c = e.AssociatedControl as Control;
if (c != null)
{
if (!recursing)
{
recursing = true;
toolTip1.SetToolTip(c, "totototo");
recursing = false;
}
}
}
Note that we have to use a flag because calling SetToolTip will cause the PopUp event to be fired again
Cheers
Upvotes: 0
Reputation: 216243
`To get or set the AccessibilityObject property, you must add a reference to the
Accessibility assembly installed with the .NET Framework`
So you just need to add this reference using the project references.
Of course the PopupEventArgs contains the control for which the tooltip is drawn and thus you could simply use e.AssociatedControl.Name
Upvotes: 2