469,924 Members | 1,431 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,924 developers. It's quick & easy.

How to suppress an event

Hi,

does anybody know how to suppress an event?
I have a combo box with the following code?

Private Sub cmb_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmb.GotFocus
cmb.DroppedDown = True
End Sub

When the user clicks on the combobox (because this piece of code) it
closes. So I would like to supress this event when the click and dropdown
event fires.
Any Clue?

Regards,

Marco Roberto

Nov 20 '05 #1
7 2395
Cut the four lines out, and rebuild it.

Regards - OHM

Marco Roberto wrote:
Hi,

does anybody know how to suppress an event?
I have a combo box with the following code?

Private Sub cmb_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmb.GotFocus
cmb.DroppedDown = True
End Sub

When the user clicks on the combobox (because this piece of code) it
closes. So I would like to supress this event when the click and
dropdown event fires.
Any Clue?

Regards,

Marco Roberto

Nov 20 '05 #2
Thank OHM, but I need to keep this code because
when the user change the focus to the combo, it
needs to open.
"One Handed Man" <Bo****@Duck.net> wrote in message
news:bq**********@hercules.btinternet.com...
Cut the four lines out, and rebuild it.

Regards - OHM

Marco Roberto wrote:
Hi,

does anybody know how to suppress an event?
I have a combo box with the following code?

Private Sub cmb_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmb.GotFocus
cmb.DroppedDown = True
End Sub

When the user clicks on the combobox (because this piece of code) it
closes. So I would like to supress this event when the click and
dropdown event fires.
Any Clue?

Regards,

Marco Roberto


Nov 20 '05 #3
Well, rather than trying to supress the even, why not supress the action.
Set a class level variable while you are performing whatever it is you are
doing and clear it afterwards. Then the the event in question test that
variable.

OHM

Marco Roberto wrote:
Thank OHM, but I need to keep this code because
when the user change the focus to the combo, it
needs to open.
"One Handed Man" <Bo****@Duck.net> wrote in message
news:bq**********@hercules.btinternet.com...
Cut the four lines out, and rebuild it.

Regards - OHM

Marco Roberto wrote:
Hi,

does anybody know how to suppress an event?
I have a combo box with the following code?

Private Sub cmb_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmb.GotFocus
cmb.DroppedDown = True
End Sub

When the user clicks on the combobox (because this piece of code) it
closes. So I would like to supress this event when the click and
dropdown event fires.
Any Clue?

Regards,

Marco Roberto

Nov 20 '05 #4
On 2003-11-27, Marco Roberto <ma***********@bancopatria.com.br> wrote:
Hi,

does anybody know how to suppress an event?
I have a combo box with the following code?

Private Sub cmb_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmb.GotFocus
cmb.DroppedDown = True
End Sub

When the user clicks on the combobox (because this piece of code) it
closes. So I would like to supress this event when the click and dropdown
event fires.
Any Clue?

Regards,

Marco Roberto


You either use a flag... Something like

Private Sub cmb_GotFocus......
Static Done As Boolean

If Not Done Then
' Do your stuff
Done = True
End If
End Sub

Or you loose the handles clause and add the event dynamically and remove
it once processed.

Public Sub Form_Load....
....
AddHandler cmb.GotFocus, AddressOf Me.cmb_GotFocus
End Sub

Private Sub cmb_GotFocus
' Do your stuff
RemoveHandler cmb.GotFocus, AddressOf Me.cmb_GotFocus
End Sub

Then the even will never fire again.
--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #5
Another alternative.

Regards - OHM

Tom Shelton wrote:
On 2003-11-27, Marco Roberto <ma***********@bancopatria.com.br> wrote:
Hi,

does anybody know how to suppress an event?
I have a combo box with the following code?

Private Sub cmb_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmb.GotFocus
cmb.DroppedDown = True
End Sub

When the user clicks on the combobox (because this piece of code) it
closes. So I would like to supress this event when the click and
dropdown event fires.
Any Clue?

Regards,

Marco Roberto


You either use a flag... Something like

Private Sub cmb_GotFocus......
Static Done As Boolean

If Not Done Then
' Do your stuff
Done = True
End If
End Sub

Or you loose the handles clause and add the event dynamically and
remove it once processed.

Public Sub Form_Load....
....
AddHandler cmb.GotFocus, AddressOf Me.cmb_GotFocus
End Sub

Private Sub cmb_GotFocus
' Do your stuff
RemoveHandler cmb.GotFocus, AddressOf Me.cmb_GotFocus
End Sub

Then the even will never fire again.

Nov 20 '05 #6
It is a good idea!

Tks

"One Handed Man" <Bo****@Duck.net> wrote in message
news:bq**********@sparta.btinternet.com...
Well, rather than trying to supress the even, why not supress the action.
Set a class level variable while you are performing whatever it is you are
doing and clear it afterwards. Then the the event in question test that
variable.

OHM

Marco Roberto wrote:
Thank OHM, but I need to keep this code because
when the user change the focus to the combo, it
needs to open.
"One Handed Man" <Bo****@Duck.net> wrote in message
news:bq**********@hercules.btinternet.com...
Cut the four lines out, and rebuild it.

Regards - OHM

Marco Roberto wrote:
Hi,

does anybody know how to suppress an event?
I have a combo box with the following code?

Private Sub cmb_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmb.GotFocus
cmb.DroppedDown = True
End Sub

When the user clicks on the combobox (because this piece of code) it
closes. So I would like to supress this event when the click and
dropdown event fires.
Any Clue?

Regards,

Marco Roberto


Nov 20 '05 #7
Hurrah !, someone is happy !

Regards - OHM

Marco Roberto wrote:
It is a good idea!

Tks

"One Handed Man" <Bo****@Duck.net> wrote in message
news:bq**********@sparta.btinternet.com...
Well, rather than trying to supress the even, why not supress the
action. Set a class level variable while you are performing whatever
it is you are doing and clear it afterwards. Then the the event in
question test that variable.

OHM

Marco Roberto wrote:
Thank OHM, but I need to keep this code because
when the user change the focus to the combo, it
needs to open.
"One Handed Man" <Bo****@Duck.net> wrote in message
news:bq**********@hercules.btinternet.com...
Cut the four lines out, and rebuild it.

Regards - OHM

Marco Roberto wrote:
> Hi,
>
> does anybody know how to suppress an event?
> I have a combo box with the following code?
>
> Private Sub cmb_GotFocus(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles cmb.GotFocus
> cmb.DroppedDown = True
> End Sub
>
> When the user clicks on the combobox (because this piece of code)
> it closes. So I would like to supress this event when the click
> and dropdown event fires.
> Any Clue?
>
> Regards,
>
> Marco Roberto

Nov 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by theintrepidfox | last post: by
1 post views Thread by seash | last post: by
5 posts views Thread by Luke Skywalker | last post: by
4 posts views Thread by =?Utf-8?B?UmljaA==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.