471,344 Members | 1,389 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,344 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 4305
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by ScottO | last post: by
reply views Thread by Doug | last post: by
2 posts views Thread by blue_nirvana | last post: by
reply views Thread by peter78 | last post: by
6 posts views Thread by tbrown | last post: by

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.