473,320 Members | 2,122 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

ComboBox SelectionChangeCommitted event fires twice

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
5 6785
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: George Hartas | last post by:
I am using Visual C# .NET 2003 to make a ComboBox accept both mouse and keyboard selection. For mouse selection code, I double-clicked ComboBox to get the default "comboBox1_SelectedIndexChanged"...
0
by: Shravan | last post by:
Hi, There is a bug in combobox selectionchangecommitted event firing, I took a combobox of style dropdownlist, I dropped down it using mouse and using Alt+Up Arrow key closed the dropdown,...
3
by: PeterZ | last post by:
G'day, After doing much searching and pinching bits of ideas from here there and everywhere I came up with a fairly 'clean' solution of including a comboBox into a dataGrid column. You can...
6
by: simchajoy2000 | last post by:
Hi, I know there are a lot of postings out there concerning this subject already, but so far I have not discovered anything that meets my specific needs. Everything I have found populates the...
1
by: Kalvin | last post by:
I have a combobox, when I use the mouse and click an item, then the SelectionChangeCommitted event fires. However, if I use the arrow keys and move up or down the list to a new item, then this...
2
by: shumaker | last post by:
I have a combobox that is very much like the one found in the RSS project here: http://msdn.microsoft.com/vstudio/express/visualCSharp/learning/ My projectNameComboBox basically is filled with a...
0
by: Frnak McKenney | last post by:
Can I use a bound ComboBox for both browsing and editing? I'm working on a small, standalone database application using Visual C#.NET 2003 and an Access data file. In order to keep the number...
10
by: Doug Bell | last post by:
Hi I am still having problems with Tabbing through a DataGrid with a DataGridComboBox Column. I need to allow the User to Type the value into the ComboBox so consequently its ComboBoxStyle is...
2
by: David Jackson | last post by:
Hello, I have an unbound DataGridView of which one of the columns is a ComboBox colum containing category data, plus an additional option called <newSo when the ComboBox is dropped down it looks...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.