how to dynamically set tootip on listbox?

  • Thread starter Thread starter GS
  • Start date Start date
how can I set tooTip on ToolTip1 for a listbox?

If you're meaning associating a tooltip with a control, simple drag a
tooltip from toolbox on your project then go to your control's
properties(eg: a button) and set " eg: tooltip on tooltip 1" property
text what you want.
 
actually, I already have tootip1 as created like you describe.


I was attempting to set the tootip dynamically based on the scrolling/item
selected on the listbox.


I guess that is not possible, so I just gave up and set the tag instead. the
user would have to request help on the listbox 1 to see the new dynamic help
content
 
It should be possible to dynamically pop up specific text in your
tooltip. I did this in a small map control i did. Basically i hooked
into the mouse move event for the control you are interested in. In the
event handler i looked to see if the tooltip was active. If active i
then analyzed where the mouse was in the control. I was able then to get
the specific information about the item that was under the mouse. You
can then set the text in the tooltip and display it. Following is the
code where i set the contents of the tool tip. It is taken out of
context but hopefully gives you the idea.
ToolTip tt = mapControl.toolTip1;
RectangleF rec = new RectangleF(x - 2,y - 2,4,4);
PointF pt = MapToScreen(mob.x,mob.y);
if (rec.Contains(pt))
{
tt.SetToolTip(mapControl, mob.TargetInfo());
tt.AutomaticDelay = 0;
tt.Active = true;
}

TargetInfo can create a pretty complex set of text. It uses a
StringBuilder to do that and you can use multiple lines of text by
Appending \n characters.

Hope this helps
Leon Lambert
 
thank you for the example code. I will give it a shot later after finishing
up the main functionalities.

I assume mob is the mouse object right?
 
No mob actually stand for Mobile Object. These are points of interest on
my map control.

Leon Lambert
 
Great. I finally got around to try out your hint. thanks to your hint..

It turns out to be real easy, nothing complicated for listbox nor textbox
controls

just add another tootip
in the control's hover event
ToolTip tt = toolTip2;
tt.SetToolTip(regexOptionListBox,
regexOptionListBox.Tag.ToString());
tt.AutomaticDelay = 0;
tt.Active = true;
for a simplified example.

To make tt context sensitive to selected listbox , I will have to use the
selected value for setToolTip accordingly instead of the tag.

I also found out
ToolTip tt = toolTip2;
is critical as direct use of toolTip2.SetToolTip(...) is not acceptable!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top