How can i increase the mousehover event timer?

M

Marc

Hi,
How can i increase the mousehover event timer?

AddHandler NewBtn.MouseHover, AddressOf Shownotes
Private Sub Shownotes(ByVal sender As System.Object, ByVal e As
System.EventArgs)
MsgBox("ttt")

Thanks!!!
 
R

rowe_newsgroups

Hi,
How can i increase the mousehover event timer?

AddHandler NewBtn.MouseHover, AddressOf Shownotes
Private Sub Shownotes(ByVal sender As System.Object, ByVal e As
System.EventArgs)
MsgBox("ttt")

Thanks!!!

How about using MouseEnter / MouseLeave instead? If you need a timer,
MouseEnter could start the timer and MouseLeave could stop it. Setting
the timer's interval property will set the "hover" time to anything
you want (as long as it's 1 millisecond or more).

However looking at your code, I wonder if using tooltips or even a
helpprovider might be better. What exactly are you trying to
accomplish?

Thanks,

Seth Rowe
 
M

Marc

How about using MouseEnter / MouseLeave instead? If you need a timer,
MouseEnter could start the timer and MouseLeave could stop it. Setting
the timer's interval property will set the "hover" time to anything
you want (as long as it's 1 millisecond or more).

However looking at your code, I wonder if using tooltips or even a
helpprovider might be better. What exactly are you trying to
accomplish?

Thanks,

Seth Rowe

Thanks Seth,

you are right...Tooltips are much better for me.

Im just looking at them now. How do i specify which text to show on a
button in code? i cant find any tooltop options i.e
newbutton.tooltiptext?
 
R

rowe_newsgroups

Thanks Seth,

you are right...Tooltips are much better for me.

Im just looking at them now. How do i specify which text to show on a
button in code? i cant find any tooltop options i.e
newbutton.tooltiptext?

The ToolTip component is what's called a provider component. It
actually provides a new property to all the applicable control and the
container (like your form) that you drop it on. With that said, after
adding a TooTip component (called ToolTip1 by default) each control
that can have a tooltip will then have a property called "ToolTip on
ToolTip1" - this is where you should set the text for the tooltip.

Thanks,

Seth Rowe
 
M

Marc

The ToolTip component is what's called a provider component. It
actually provides a new property to all the applicable control and the
container (like your form) that you drop it on. With that said, after
adding a TooTip component (called ToolTip1 by default) each control
that can have a tooltip will then have a property called "ToolTip on
ToolTip1" - this is where you should set the text for the tooltip.

Thanks,

Seth Rowe- Hide quoted text -

- Show quoted text -

OK thanks
 
M

Marc

OK thanks- Hide quoted text -

- Show quoted text -

HI,

I have a set of dynamically created buttons and textbox's. Each button
is linked to a textbox using the accessiblename property. I want to
show a button tool tip containing the text box's text. My code so far
is below although i know this wont work!

any help is greatly appreciated.


Private Sub AddNewDriverToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
AddNewDriverToolStripMenuItem.Click

Dim NewBtn As New Button()
NewBtn.AccessibleName = CStr(Now)
Me.Controls.Add(NewBtn)


Dim NewTxt As New RichTextBox
NewTxt.AccessibleName = NewBtn.AccessibleName
Me.Controls.Add(NewTxt)

Dim ctlControl As Control
Dim s As String
For Each ctlControl In Me.Controls
If TypeOf ctlControl Is RichTextBox And
ctlControl.AccessibleName = NewBtn.AccessibleName Then
s = NewBtn.Text
End If
Next

ToolTip1.SetToolTip(NewBtn, s)
 
R

rowe_newsgroups

HI,

I have a set of dynamically created buttons and textbox's. Each button
is linked to a textbox using the accessiblename property. I want to
show a button tool tip containing the text box's text. My code so far
is below although i know this wont work!

any help is greatly appreciated.

Private Sub AddNewDriverToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
AddNewDriverToolStripMenuItem.Click

Dim NewBtn As New Button()
NewBtn.AccessibleName = CStr(Now)
Me.Controls.Add(NewBtn)

Dim NewTxt As New RichTextBox
NewTxt.AccessibleName = NewBtn.AccessibleName
Me.Controls.Add(NewTxt)

Dim ctlControl As Control
Dim s As String
For Each ctlControl In Me.Controls
If TypeOf ctlControl Is RichTextBox And
ctlControl.AccessibleName = NewBtn.AccessibleName Then
s = NewBtn.Text
End If
Next

ToolTip1.SetToolTip(NewBtn, s)

Well, in your for each loop you are setting the string "s" to the
value of the button's text, not the RichTextBox's text. Also, this
loop is only run when the user clicks the
AddNewDriverToolStripMenuItem, meaning the tooltips won't be updated
real time.

Also you may look at the tag property. With it you can actually set
the value to an object (like say a certain RichTextBox) and then avoid
having to do a for each loop to find a particular control. Besides, a
person using a Accessibility settings will get upset with your
AccessibleNames :)

Instead, I would suggest you add a new usercontrol to your program. To
this user control add a RichTextBox a Button, and a ToolTip - leave
the default names for now. Next, add an event handler for the
RichTextBox's TextChanged Event :

Private Sub RichTextBox1_TextChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
RichTextBox1.TextChanged
ToolTip1.SetToolTip(Me.Button1, RichTextBox1.Text)
End Sub

This will update the ToolTip for the button whenever the text changes
in the RichTextBox. After you get everything laid out in the user
control the way you want it, instead of adding the RichTextBox and
Button to the form, just add the UserControl you just created. This
way everything is neatly self contained (encapsulated) and you don't
need to worry about it in the form it will be added to. Any features
that need to be exposed by the UserControl to the outside should be
wrapped in a property (or by bubbling events if you need to expose an
event), as it is generally a bad idea to expose an entire object.

Any further questions please ask!

Thanks,

Seth Rowe
 
M

Marc

Well, in your for each loop you are setting the string "s" to the
value of the button's text, not the RichTextBox's text. Also, this
loop is only run when the user clicks the
AddNewDriverToolStripMenuItem, meaning the tooltips won't be updated
real time.

Also you may look at the tag property. With it you can actually set
the value to an object (like say a certain RichTextBox) and then avoid
having to do a for each loop to find a particular control. Besides, a
person using a Accessibility settings will get upset with your
AccessibleNames :)

Instead, I would suggest you add a new usercontrol to your program. To
this user control add a RichTextBox a Button, and a ToolTip - leave
the default names for now. Next, add an event handler for the
RichTextBox's TextChanged Event :

Private Sub RichTextBox1_TextChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
RichTextBox1.TextChanged
ToolTip1.SetToolTip(Me.Button1, RichTextBox1.Text)
End Sub

This will update the ToolTip for the button whenever the text changes
in the RichTextBox. After you get everything laid out in the user
control the way you want it, instead of adding the RichTextBox and
Button to the form, just add the UserControl you just created. This
way everything is neatly self contained (encapsulated) and you don't
need to worry about it in the form it will be added to. Any features
that need to be exposed by the UserControl to the outside should be
wrapped in a property (or by bubbling events if you need to expose an
event), as it is generally a bad idea to expose an entire object.

Any further questions please ask!

Thanks,

Seth Rowe- Hide quoted text -

- Show quoted text -

Thank you very much!. extremely good advice.
 
M

Marc

Well, in your for each loop you are setting the string "s" to the
value of the button's text, not the RichTextBox's text. Also, this
loop is only run when the user clicks the
AddNewDriverToolStripMenuItem, meaning the tooltips won't be updated
real time.

Also you may look at the tag property. With it you can actually set
the value to an object (like say a certain RichTextBox) and then avoid
having to do a for each loop to find a particular control. Besides, a
person using a Accessibility settings will get upset with your
AccessibleNames :)

Instead, I would suggest you add a new usercontrol to your program. To
this user control add a RichTextBox a Button, and a ToolTip - leave
the default names for now. Next, add an event handler for the
RichTextBox's TextChanged Event :

Private Sub RichTextBox1_TextChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
RichTextBox1.TextChanged
ToolTip1.SetToolTip(Me.Button1, RichTextBox1.Text)
End Sub

This will update the ToolTip for the button whenever the text changes
in the RichTextBox. After you get everything laid out in the user
control the way you want it, instead of adding the RichTextBox and
Button to the form, just add the UserControl you just created. This
way everything is neatly self contained (encapsulated) and you don't
need to worry about it in the form it will be added to. Any features
that need to be exposed by the UserControl to the outside should be
wrapped in a property (or by bubbling events if you need to expose an
event), as it is generally a bad idea to expose an entire object.

Any further questions please ask!

Thanks,

Seth Rowe- Hide quoted text -

- Show quoted text -

Seth,

quick question....if i use a Tag instead of accessiblename how can
search for a specific control without using loop?
 
R

rowe_newsgroups

Seth,

quick question....if i use a Tag instead of accessiblename how can
search for a specific control without using loop?

It depends - which control are you trying to find and why do you need
to find it?

Thanks,

Seth Rowe
 
M

Marc

It depends - which control are you trying to find and why do you need
to find it?

Thanks,

Seth Rowe- Hide quoted text -

- Show quoted text -

OK,

so my users can dynamically add buttons to a form...basically i am
trying to allow the users to save text notes to a button. So when the
user double clicks on a button a text box appears.
As multiple buttons can be added i need a way to tie each button to
its text box. When the user creates a button I also create a new text
box automatically. Before i was populating the accessible name
property with the creation date time to tie the two together.

So when a user double clicks the button i was searching through every
control that matches the accessible name to show the appropriate text
box....make sense?
 
R

rowe_newsgroups

OK,

so my users can dynamically add buttons to a form...basically i am
trying to allow the users to save text notes to a button. So when the
user double clicks on a button a text box appears.
As multiple buttons can be added i need a way to tie each button to
its text box. When the user creates a button I also create a new text
box automatically. Before i was populating the accessible name
property with the creation date time to tie the two together.

So when a user double clicks the button i was searching through every
control that matches the accessible name to show the appropriate text
box....make sense?

Ok, store the richtextbox you want to access in the Tag property of
it's associated button.

Even better you should use my suggestion of putting the button and
textbox into a user control and adding the user control at runtime
instead of the button and textbox. That way the usercontrol manages
it's controls (the textbox and button) while the form only has to
worry about adding the usercontrols. Is there something you don't
understand about this approach?

Thanks,

Seth Rowe
 
M

Marc

Ok, store the richtextbox you want to access in the Tag property of
it's associated button.

Even better you should use my suggestion of putting the button and
textbox into a user control and adding the user control at runtime
instead of the button and textbox. That way the usercontrol manages
it's controls (the textbox and button) while the form only has to
worry about adding the usercontrols. Is there something you don't
understand about this approach?

Thanks,

Seth Rowe- Hide quoted text -

- Show quoted text -

OK thanks very much for the help
 

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