473,224 Members | 1,487 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,224 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 4385
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.