Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable control events or disable procedure 1

Status
Not open for further replies.

mattscotney

Programmer
Jul 31, 2002
57
AU
Hi all,

Is it possible to disable specific events of a control while another procedure is running?

eg. Disable a the valueChanged event of a Horizontal scroll bar.

I am not trying to disable the actual control itself, only disable specific events while another procedure is running.

Another way to do it would be if I could disable one procedure while another is running, but how?

Thanks,
Matt
 
Hi,
You could do something like
-----------------------------------------------------------
Private Sub MyTextChanges(ByVal sender As Object, ByVal e As System.EventArgs)
MessageBox.Show("Change")
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Set button text
Button1.Text = "Add hndl"
Button1_Click(Button1, New System.EventArgs())
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Button1.Text = "Remove hndl" Then
'Remove handler
RemoveHandler TextBox1.TextChanged, AddressOf MyTextChanges
Button1.Text = "Add hndl"
Else
'Add handler
AddHandler TextBox1.TextChanged, AddressOf MyTextChanges
Button1.Text = "Remove hndl"
End If
End Sub
-----------------------------------------------------------


Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Thanks Sunaj, you set me on the right track.

All I have to do is:

'Turn off the event:
RemoveHandler "object.event", AddressOf Me."Name of event procedure"

'Run some code, procedure, or function"
msgbox("hello World")

'Turn the event back on:
AddHandler "object.event", AddressOf Me."Name of event procedure"

Thanks again Sunaj, I will give you a star as you set me on the right track.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top