Custom Control and ToolTips?

T

Tinus

Hello all,

[Sorry for x-posting but did not know in which group someone could help me]

I've created a custom control that draws a monthly schedule (using the Draw
function in C#). Basically it draws 31 boxes and writes the day number in
every box.

This works great. But I now want to show a different tooltip for every day.
For now I found out that I can add a tooltip for the entire custom control
but how to create a tooltip for every box that I've drawn in my custom
control??

Hope someone can shed a light on this problem for me!

Thanks in advance;
Regards,
Tinus
 
A

adnan boz

Hi,

Some possibilities;
1) You may already tested this but in case of you don't; Don't draw boxes,
create every box dynamicaly from a control. You can then set seperated
tooltips for every box. In my opinion, if you don't have performance
problems every single day should be a class and it would best described with
a user/custom control.
2) Make your own custom tooltip control from a label or something else and
show it at the calculated positions. A timer control should be enough to
show/hide it after a while.
3) As an idea; Build an invisible user/custom control and assign your
tooltip. Reposition it right under your mouse pointer if the pointer is over
a box, it will display the tooltip. (You can limit the draw region to become
an invisible control)

Good Luck,
Adnan


Hello all,

[Sorry for x-posting but did not know in which group someone could help me]

I've created a custom control that draws a monthly schedule (using the Draw
function in C#). Basically it draws 31 boxes and writes the day number in
every box.

This works great. But I now want to show a different tooltip for every day.
For now I found out that I can add a tooltip for the entire custom control
but how to create a tooltip for every box that I've drawn in my custom
control??

Hope someone can shed a light on this problem for me!

Thanks in advance;
Regards,
Tinus
 
T

Tinus

Adnan,

Thanks for your help....
1) Hmmmm, this would mean that I must recreate the entire control (and I'm
already so far :-( )
2) Can you be more specific how to do this? I've tried to create a new form
with no border and show it using the MouseHover (and MouseMove) events. The
problem is that when I show the form it has the focus and can't get back to
my control.....
3) Is a dirty workable way, but I don't like it to much.

I'm still learning C# so bear with me :)

Thanks again!
Tinus
 
A

adnan boz

Hi,
A form would not be the best solution for a tooltip. Create a user or custom
control instead.
Also u could use a label with FixedSingle border as well. Examine a real
tooltip and its behaviour, u should find out how to build the same.

Good Luck,
Adnan

Adnan,

Thanks for your help....
1) Hmmmm, this would mean that I must recreate the entire control (and I'm
already so far :-( )
2) Can you be more specific how to do this? I've tried to create a new form
with no border and show it using the MouseHover (and MouseMove) events. The
problem is that when I show the form it has the focus and can't get back to
my control.....
3) Is a dirty workable way, but I don't like it to much.

I'm still learning C# so bear with me :)

Thanks again!
Tinus
 
J

James Westgate

You can use a single tooltip control and just display it depending on the
location of your cursor, using the Tooltip class. Use the SetTooltip method
to assciate the text with the control. Destroy and recreate the object
everytime your tooltip changes.

James
 
T

Tinus

Ah, yes, offcourse.... that is a good solution and simple.... Thanks James!!

Tinus

James Westgate said:
You can use a single tooltip control and just display it depending on the
location of your cursor, using the Tooltip class. Use the SetTooltip
method to assciate the text with the control. Destroy and recreate the
object everytime your tooltip changes.

James


--
Create interactive diagrams and flowcharts with ERM Diagram at
http://www.crainiate.net

Take the ERM Tour at http://www.flowchartcontrol.com



Tinus said:
Hello all,

[Sorry for x-posting but did not know in which group someone could help
me]

I've created a custom control that draws a monthly schedule (using the
Draw function in C#). Basically it draws 31 boxes and writes the day
number in every box.

This works great. But I now want to show a different tooltip for every
day. For now I found out that I can add a tooltip for the entire custom
control but how to create a tooltip for every box that I've drawn in my
custom control??

Hope someone can shed a light on this problem for me!

Thanks in advance;
Regards,
Tinus
 
T

Tinus

James,

I did what you recommended and it works.... however I have a small problem
now and that is that as soon as I enter my 'custom' control the tooltip is
displayed inmediatly :-(

I use the MouseMove event of my custom control to get the location of the
mouse and using that to figure out where the mouse is and what the tooltip
has to display. So in the MouseMove event I set the tooltip using the
SetToolTip function.

I've set the AutoPopDelay to 5000 (5sec) and the InitialDelay and
ReshowDelay to 1000 (1sec). But still the tooltip is display as soon as I
enter the control with the mouse (no 1sec delay :-( ). This is probably
because the SetToolTip function is called as soon as I enter the control
because of the MouseMove event?

If I use the MouseHover event then the tooltip is only displayed once when
the mouse is inside the control...

Do you or someone else have a solution for this?
Thanks in advance!

With regards,
Tinus

James Westgate said:
You can use a single tooltip control and just display it depending on the
location of your cursor, using the Tooltip class. Use the SetTooltip
method to assciate the text with the control. Destroy and recreate the
object everytime your tooltip changes.

James


--
Create interactive diagrams and flowcharts with ERM Diagram at
http://www.crainiate.net

Take the ERM Tour at http://www.flowchartcontrol.com



Tinus said:
Hello all,

[Sorry for x-posting but did not know in which group someone could help
me]

I've created a custom control that draws a monthly schedule (using the
Draw function in C#). Basically it draws 31 boxes and writes the day
number in every box.

This works great. But I now want to show a different tooltip for every
day. For now I found out that I can add a tooltip for the entire custom
control but how to create a tooltip for every box that I've drawn in my
custom control??

Hope someone can shed a light on this problem for me!

Thanks in advance;
Regards,
Tinus
 
J

James Westgate

HI,

Do you create a new tooltip object everytime the mouse enters a new calendar
day? The tooltip control considers your control as one "region" so will
start counting the delay immedialtely.

James


Tinus said:
James,

I did what you recommended and it works.... however I have a small problem
now and that is that as soon as I enter my 'custom' control the tooltip is
displayed inmediatly :-(

I use the MouseMove event of my custom control to get the location of the
mouse and using that to figure out where the mouse is and what the tooltip
has to display. So in the MouseMove event I set the tooltip using the
SetToolTip function.

I've set the AutoPopDelay to 5000 (5sec) and the InitialDelay and
ReshowDelay to 1000 (1sec). But still the tooltip is display as soon as I
enter the control with the mouse (no 1sec delay :-( ). This is probably
because the SetToolTip function is called as soon as I enter the control
because of the MouseMove event?

If I use the MouseHover event then the tooltip is only displayed once when
the mouse is inside the control...

Do you or someone else have a solution for this?
Thanks in advance!

With regards,
Tinus

James Westgate said:
You can use a single tooltip control and just display it depending on the
location of your cursor, using the Tooltip class. Use the SetTooltip
method to assciate the text with the control. Destroy and recreate the
object everytime your tooltip changes.

James


--
Create interactive diagrams and flowcharts with ERM Diagram at
http://www.crainiate.net

Take the ERM Tour at http://www.flowchartcontrol.com



Tinus said:
Hello all,

[Sorry for x-posting but did not know in which group someone could help
me]

I've created a custom control that draws a monthly schedule (using the
Draw function in C#). Basically it draws 31 boxes and writes the day
number in every box.

This works great. But I now want to show a different tooltip for every
day. For now I found out that I can add a tooltip for the entire custom
control but how to create a tooltip for every box that I've drawn in my
custom control??

Hope someone can shed a light on this problem for me!

Thanks in advance;
Regards,
Tinus
 
T

Tinus

Ehhmm,

The ToolTip object is created once (in the InitializeComponent function) and
the SetToolTip is called everytime the MouseMove event is triggert. In the
MouseMove event I calculate the position of the mouse relative to the drawn
schedule and set the ToolTip accordingly.

Do you think I need to create a new ToolTip every time the mouse is over a
new day using the MouseMove event (by disposing of it and recreate it by
using 'new ToolTip()' )? And I can do this only by using the MouseMove
event (only way of knowing where the mouse is on the control)...

I'm still learing c# so maybe that's way I don't fully know how to implement
your suggestion :-(

This is what I've got so far. In the MouseMove event I calculate using the
mouse position coordinates where the mouse is (in which day box of the
schedule). Occording to that I set the ToolTip to the day on which the mouse
is. This works perfectly. As soon as I enter the 'custom' control on a day
the tooltip is shown inmediately with the day number in it (no hover delay!!
even when the predelay is set). When I don't move the mouse it dissapears
after the preset 5sec. However, as soon as I move it, it is shown again,
again no delay. If I move to a different day box the tooltip is inmediatly
changed to the new text (day number) without dissapearing...

Hopefully you understand my problem and know what I'm doing wrong...

Thanks for your help and time.

Regards,
Tinus


James Westgate said:
HI,

Do you create a new tooltip object everytime the mouse enters a new
calendar day? The tooltip control considers your control as one "region"
so will start counting the delay immedialtely.

James


Tinus said:
James,

I did what you recommended and it works.... however I have a small
problem now and that is that as soon as I enter my 'custom' control the
tooltip is displayed inmediatly :-(

I use the MouseMove event of my custom control to get the location of the
mouse and using that to figure out where the mouse is and what the
tooltip has to display. So in the MouseMove event I set the tooltip using
the SetToolTip function.

I've set the AutoPopDelay to 5000 (5sec) and the InitialDelay and
ReshowDelay to 1000 (1sec). But still the tooltip is display as soon as I
enter the control with the mouse (no 1sec delay :-( ). This is probably
because the SetToolTip function is called as soon as I enter the control
because of the MouseMove event?

If I use the MouseHover event then the tooltip is only displayed once
when the mouse is inside the control...

Do you or someone else have a solution for this?
Thanks in advance!

With regards,
Tinus

James Westgate said:
You can use a single tooltip control and just display it depending on
the location of your cursor, using the Tooltip class. Use the SetTooltip
method to assciate the text with the control. Destroy and recreate the
object everytime your tooltip changes.

James


--
Create interactive diagrams and flowcharts with ERM Diagram at
http://www.crainiate.net

Take the ERM Tour at http://www.flowchartcontrol.com



message Hello all,

[Sorry for x-posting but did not know in which group someone could help
me]

I've created a custom control that draws a monthly schedule (using the
Draw function in C#). Basically it draws 31 boxes and writes the day
number in every box.

This works great. But I now want to show a different tooltip for every
day. For now I found out that I can add a tooltip for the entire custom
control but how to create a tooltip for every box that I've drawn in my
custom control??

Hope someone can shed a light on this problem for me!

Thanks in advance;
Regards,
Tinus
 
T

Tinus

James,

Thanks man! It worked! In the MouseMove event I calculate the position and
look if the mouse has not left a certain daybox.... if it has, I destroy the
ToolTip object and recreate one and set the ToolTip text.... now the ToolTip
appearse after a certain time and not inmediatle anymore :)

Thanks again for your help!
Tinus
- The Netherlands -

James Westgate said:
HI,

Do you create a new tooltip object everytime the mouse enters a new
calendar day? The tooltip control considers your control as one "region"
so will start counting the delay immedialtely.

James


Tinus said:
James,

I did what you recommended and it works.... however I have a small
problem now and that is that as soon as I enter my 'custom' control the
tooltip is displayed inmediatly :-(

I use the MouseMove event of my custom control to get the location of the
mouse and using that to figure out where the mouse is and what the
tooltip has to display. So in the MouseMove event I set the tooltip using
the SetToolTip function.

I've set the AutoPopDelay to 5000 (5sec) and the InitialDelay and
ReshowDelay to 1000 (1sec). But still the tooltip is display as soon as I
enter the control with the mouse (no 1sec delay :-( ). This is probably
because the SetToolTip function is called as soon as I enter the control
because of the MouseMove event?

If I use the MouseHover event then the tooltip is only displayed once
when the mouse is inside the control...

Do you or someone else have a solution for this?
Thanks in advance!

With regards,
Tinus

James Westgate said:
You can use a single tooltip control and just display it depending on
the location of your cursor, using the Tooltip class. Use the SetTooltip
method to assciate the text with the control. Destroy and recreate the
object everytime your tooltip changes.

James


--
Create interactive diagrams and flowcharts with ERM Diagram at
http://www.crainiate.net

Take the ERM Tour at http://www.flowchartcontrol.com



message Hello all,

[Sorry for x-posting but did not know in which group someone could help
me]

I've created a custom control that draws a monthly schedule (using the
Draw function in C#). Basically it draws 31 boxes and writes the day
number in every box.

This works great. But I now want to show a different tooltip for every
day. For now I found out that I can add a tooltip for the entire custom
control but how to create a tooltip for every box that I've drawn in my
custom control??

Hope someone can shed a light on this problem for me!

Thanks in advance;
Regards,
Tinus
 

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