WinForm PictureBox with multiple tool tips

J

Jon

Hello all,

I have a little c# app that draws a rectangle onto an image loaded
into
a PictureBox, this all works fine. However, I'd like to make it such
that a tooltip will appear when I hover over one of the newly drawn
rectangles. Any suggestions on how I could do this?

Regards.
 
P

Peter Duniho

Jon said:
Hello all,

I have a little c# app that draws a rectangle onto an image loaded
into
a PictureBox, this all works fine. However, I'd like to make it such
that a tooltip will appear when I hover over one of the newly drawn
rectangles. Any suggestions on how I could do this?

AFAIK, the built-in tooltip class is one-per-control only. So, you
would have to create "dummy" controls for each rectangle and assign a
tooltip to each one.

Alternatively, you can of course implement the tooltip behavior
yourself. It's not that hard: just handle mouse move events, watching
for when the mouse cursor winds up within a rectangle, starting a timer,
and if the timer expires before the mouse moves out, displaying the
tooltip yourself (either in-place in the control you're already drawing,
or as its own control, perhaps a Label instance).

There are lots of details to get right, including the coordinates, timer
starting and stopping, etc. but none of it is terribly tricky. It's
just a matter of putting the code down.

Pete
 

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

Top