473,414 Members | 1,605 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,414 software developers and data experts.

ComboBox.SelectedIndexChanged

I need help!! I'm using the selectedindexchanged event of a combobox to fill
another combobox according to the selected value of the first one, but the
combobox_selectedindexchanged happens twice so the same routine of searching
data occurs twice!!! So my application takes twice the time it should take. I
debug that part of my application, and when it reaches the end sub of that
subrutine the first time, the event takes place again, so the control doesn't
return to the function it called as soon as it finishes the sub but after the
second time is done.
What can I do?? Help me please, I would really appreciate it.
--
From Bolivia
Jul 21 '05 #1
3 4400
Hi,
Is this a Winform. Sounds strange..
Can you post the code.

Happy Coding

"Ceci" <Ce**@discussions.microsoft.com> wrote in message
news:46**********************************@microsof t.com...
I need help!! I'm using the selectedindexchanged event of a combobox to fill another combobox according to the selected value of the first one, but the
combobox_selectedindexchanged happens twice so the same routine of searching data occurs twice!!! So my application takes twice the time it should take. I debug that part of my application, and when it reaches the end sub of that
subrutine the first time, the event takes place again, so the control doesn't return to the function it called as soon as it finishes the sub but after the second time is done.
What can I do?? Help me please, I would really appreciate it.
--
From Bolivia

Jul 21 '05 #2
Hi, it's a winform. I have two comboboxes: cmbLines and cmbProducts. When you
choose one line you search for the products of that line and you display them
in the cmbproducts.
Here is the code:

Private Sub cmbLines_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cmbLines.SelectedIndexChanged
Dim ObjProducts As BaseProducts
Dim DtProducts As DataTable

ObjProduct = New BaseProducts(ConSql)
DtProducts = New DataTable
DtProducts = ObjProducts.BringProducts(cmbLines.SelectedValue)
cmbProducts.DataSource = DtProducts
ObjProducts.Dispose()
End Sub

Private Sub cmbProducts_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles cmbProducts.SelectedIndexChanged
Dim ObjBaseProducts As BaseProducts
Dim ObjProduct As CProduct

ObjBaseProducts = New BaseProducts(ConSql)
ObjProduct = New CProduct

ObjProduct =
ObjBaseProducts.BringProductDetail(cmbProductos.Se lectedValue)
lblCodig.Text = ObjProduct.Cod
lblName.Text = ObjProduct.Name
lblExis.Text = ObjProducto.Exist
lblPrice.Text = ObjProducto.Price
lblVencDate.Text = Format(ObjProduct.VencDate, "dd/M/yyyy")
lblUnitBox.Text = "C: " & ObjProduct.BoxQty
ObjBaseProducts.Dispose()
End Sub

When cmbProducts.DataSource = DtProducts happens, it goes to
cmbProducts_SelectedIndexChanged but when it reaches the
cmbProducts_SelectedIndexChanged's end sub it goes again to the beginnig of
that routine.

I don't understand. Please help me. Thanks.

Jul 21 '05 #3
Hi, it's a winform. I have two comboboxes: cmbLines and cmbProducts. When you
choose one line you search for the products of that line and you display them
in the cmbproducts.
Here is the code:

Private Sub cmbLines_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cmbLines.SelectedIndexChanged
Dim ObjProducts As BaseProducts
Dim DtProducts As DataTable

ObjProduct = New BaseProducts(ConSql)
DtProducts = New DataTable
DtProducts = ObjProducts.BringProducts(cmbLines.SelectedValue)
cmbProducts.DataSource = DtProducts
ObjProducts.Dispose()
End Sub

Private Sub cmbProducts_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles cmbProducts.SelectedIndexChanged
Dim ObjBaseProducts As BaseProducts
Dim ObjProduct As CProduct

ObjBaseProducts = New BaseProducts(ConSql)
ObjProduct = New CProduct

ObjProduct =
ObjBaseProducts.BringProductDetail(cmbProductos.Se lectedValue)
lblCodig.Text = ObjProduct.Cod
lblName.Text = ObjProduct.Name
lblExis.Text = ObjProducto.Exist
lblPrice.Text = ObjProducto.Price
lblVencDate.Text = Format(ObjProduct.VencDate, "dd/M/yyyy")
lblUnitBox.Text = "C: " & ObjProduct.BoxQty
ObjBaseProducts.Dispose()
End Sub

When cmbProducts.DataSource = DtProducts happens, it goes to
cmbProducts_SelectedIndexChanged but when it reaches the
cmbProducts_SelectedIndexChanged's end sub it goes again to the beginnig of
that routine.

I don't understand. Please help me. Thanks.

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Anthony | last post by:
is there a way to stop combox from firing SelectedIndexChanged events on loading when it is databinded? everytime my form loads, SelectedIndexChanged fires 4 times? using System; using...
3
by: ScottO | last post by:
I would like the user to have to select something in a System.Windows.Forms.ComboBox. private void MyForm_Load(object sender, System.EventArgs e) { ... comboBox.DataSource = data;...
0
by: Doug | last post by:
This is a repost of an item that I still cannot resolve. I have 3 combo boxes. The first leads to the second to the third. When I have selected a value in the second box, the third box shows...
4
by: Keith | last post by:
Hello - this started out as a minor annoyance - and now is starting to bother me more and more - I'm hoping someone can help me. I would like to have a combobox display - NOT initially be blank...
7
by: sparkle | last post by:
Hi Everybody, I'm filling a combobox from a class, which works fine on it's own. But when I insert code to fill in other controls something in the combobox fill is causing the...
2
by: blue_nirvana | last post by:
I use a AddHandler statement in the load event of a form to assoicate a routine with a combobox. When I populate the form, I select the approiate value from the combobox by using...
4
by: Joe Schmoe | last post by:
All I want to to be able to take a two-column DataReader (One column with the Item ID number, the other with Item Description text) and load it into a Windows Forms ComboBox (Set to DropDownList...
0
by: peter78 | last post by:
I wanted to implement an autocomplete feature on the combobox where you would type in partial text and it would try to match it for you. It doesn't exist in .Net yet, but I'm guessing it will in...
6
by: tbrown | last post by:
I have a combobox with items like this: {one,two,three}. The selected index is 0, so "one" appears in the combobox text. When the user drops down the list, and selects "two", for example, I...
2
by: tshad | last post by:
In my VS 2003 Windows Forms page, when I initially fill my ComboBox (SystemList), it goes to the SelectedIndexChanged event which calls the Loademails() function. I then call it again in the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.