By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,865 Members | 1,725 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,865 IT Pros & Developers. It's quick & easy.

ComboBox SelectionChangeCommitted event fires twice

P: n/a
SelectionChangeCommitted event fires twice

Hi,

Please have a look at the following ComboBox behavior.
With the code below, if you click in the dropdown list with the mouse
to select an item , everything is fine.

But if you use the Enter key to select in the dropdown list, the
SelectionChangeCommitted event is fired twice.

How can I cancel the second event firing ?

Thanks
ML
'#### BEGIN CODE ##################

Private Sub FormTest_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList

ComboBox1.Items.Add("My item 1")
ComboBox1.Items.Add("My item 2")
ComboBox1.Items.Add("My item 3")
End Sub

Private Sub ComboBox1_SelectionChangeCommitted(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
ComboBox1.SelectionChangeCommitted

MsgBox("test")

End Sub

'#### END CODE ##################

Jul 19 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi ML,
I have tested it with VS2005. This code does not show the problem you
report (?).

-tom

do**@globetrotter.net ha scritto:
SelectionChangeCommitted event fires twice

Hi,

Please have a look at the following ComboBox behavior.
With the code below, if you click in the dropdown list with the mouse
to select an item , everything is fine.

But if you use the Enter key to select in the dropdown list, the
SelectionChangeCommitted event is fired twice.

How can I cancel the second event firing ?

Thanks
ML
'#### BEGIN CODE ##################

Private Sub FormTest_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList

ComboBox1.Items.Add("My item 1")
ComboBox1.Items.Add("My item 2")
ComboBox1.Items.Add("My item 3")
End Sub

Private Sub ComboBox1_SelectionChangeCommitted(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
ComboBox1.SelectionChangeCommitted

MsgBox("test")

End Sub

'#### END CODE ##################
Jul 19 '06 #2

P: n/a
Mic
Hi Tom,

Sorry I did not specify that I'm using VS .Net 2003.
to**************@uniroma1.it wrote:
Hi ML,
I have tested it with VS2005. This code does not show the problem you
report (?).

-tom

do**@globetrotter.net ha scritto:
SelectionChangeCommitted event fires twice

Hi,

Please have a look at the following ComboBox behavior.
With the code below, if you click in the dropdown list with the mouse
to select an item , everything is fine.

But if you use the Enter key to select in the dropdown list, the
SelectionChangeCommitted event is fired twice.

How can I cancel the second event firing ?

Thanks
ML
'#### BEGIN CODE ##################

Private Sub FormTest_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList

ComboBox1.Items.Add("My item 1")
ComboBox1.Items.Add("My item 2")
ComboBox1.Items.Add("My item 3")
End Sub

Private Sub ComboBox1_SelectionChangeCommitted(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
ComboBox1.SelectionChangeCommitted

MsgBox("test")

End Sub

'#### END CODE ##################
Jul 20 '06 #3

P: n/a
ML,

In addition to Tommasso, I did not test it, but found it curious that you
would get an error with this code.

Are you sure that the error is not because that you are selecting inside the
event?

Cor

<do**@globetrotter.netschreef in bericht
news:11**********************@m79g2000cwm.googlegr oups.com...
SelectionChangeCommitted event fires twice

Hi,

Please have a look at the following ComboBox behavior.
With the code below, if you click in the dropdown list with the mouse
to select an item , everything is fine.

But if you use the Enter key to select in the dropdown list, the
SelectionChangeCommitted event is fired twice.

How can I cancel the second event firing ?

Thanks
ML
'#### BEGIN CODE ##################

Private Sub FormTest_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList

ComboBox1.Items.Add("My item 1")
ComboBox1.Items.Add("My item 2")
ComboBox1.Items.Add("My item 3")
End Sub

Private Sub ComboBox1_SelectionChangeCommitted(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
ComboBox1.SelectionChangeCommitted

MsgBox("test")

End Sub

'#### END CODE ##################

Jul 20 '06 #4

P: n/a
do**@globetrotter.net wrote:
SelectionChangeCommitted event fires twice

Hi,

Please have a look at the following ComboBox behavior.
With the code below, if you click in the dropdown list with the mouse
to select an item , everything is fine.

But if you use the Enter key to select in the dropdown list, the
SelectionChangeCommitted event is fired twice.

How can I cancel the second event firing ?
Reproduced in 2003 - thanks for the complete sample.

I think your options are:

- upgrade (I know this probably isn't an available option)
- rework your app so that it isn't a problem that this event fires twice
in these circumstances - how about you only do whatever you want to do
on selection change if the selection *actually changes* - ie, keep a
separate track of what the current selection is, and if you get a
SelectionChangeCommitted but the new selection is the same as the
current stored selection, don't do anything.

--
Larry Lard
la*******@googlemail.com
The address is real, but unread - please reply to the group
For VB and C# questions - tell us which version
Jul 20 '06 #5

P: n/a
Docw,

I call the combobox for myself always the bugbox.

By the way, you know that there is a servicepack for Net 1.1, I don't know
if your problem is fixed in that.

http://www.microsoft.com/downloads/d...7-034d1e7cf3a3

Cor


<do**@globetrotter.netschreef in bericht
news:11**********************@m79g2000cwm.googlegr oups.com...
SelectionChangeCommitted event fires twice

Hi,

Please have a look at the following ComboBox behavior.
With the code below, if you click in the dropdown list with the mouse
to select an item , everything is fine.

But if you use the Enter key to select in the dropdown list, the
SelectionChangeCommitted event is fired twice.

How can I cancel the second event firing ?

Thanks
ML
'#### BEGIN CODE ##################

Private Sub FormTest_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList

ComboBox1.Items.Add("My item 1")
ComboBox1.Items.Add("My item 2")
ComboBox1.Items.Add("My item 3")
End Sub

Private Sub ComboBox1_SelectionChangeCommitted(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
ComboBox1.SelectionChangeCommitted

MsgBox("test")

End Sub

'#### END CODE ##################

Jul 20 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.