Problema Combo Box

08/02/2005 - 20:15 por Jonapa | Informe spam
Hola Grupo

estoy trabjando con vb.net, estoy llenando combobox segun sea el caso de la
seleccion, por ejemplo :

se carga el primer combobox(cbbestado) al momento de iniciar
el formulario , una vez cargado el formulario escojo en valor que tiene el
combobox estado este a su vez cargara combobox municipio, asi susevicamente.

La pregunta es :
cuando selecciono un valor del combobox de estado el cual tiene un evento
(CbbEstado_SelectedValueChanged) se executa este evento como unas tres a
cuatro veces, y esto da por consecuencia que lo que contenga el evento se
ejecute la intruccion select tres o cuatro veces, esto lo quise controlar por
medio de una bandera pero sigue haciendo lo mismo. espero me haya explidado.

tambien he puestos otras propiedades para eliminar el contenido de la
informacion para que no se ejecute varias veces pero sigue igual.

estoy trabajando con vb.net 2002

ojala me puedan ayudar.

de antemano muchas gracias

anexo codigo



Sub CARGA_COMBOS()

Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
Dim DSEdo As New DataSet()
L_SQL = "SELECT * FROM ESTADO (INDEX=PK_ESTADO)"
SDAGral.SelectCommand.Connection = DB
SDAGral.SelectCommand.CommandText = L_SQL
SDAGral.Fill(DSEdo, "ESTADO")
With CbbEstado
.DataSource = DSEdo.Tables("ESTADO")
.ValueMember = "EDO_CLAVE"
L_BANDERA_EDO = True
.DisplayMember = ("EDO_DESCRIPCION")
End With
CbbEstado.SelectedIndex = 0
Me.Cursor = System.Windows.Forms.Cursors.Default
End Sub

Private Sub CbbEstado_SelectedValueChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles CbbEstado.SelectedIndexChanged

If L_BANDERA_EDO = True Then
Dim DSMunicipio As New DataSet()
CbbMunicipio.DataSource = Nothing
CbbLocalidad.DataSource = Nothing
CbbColonia.DataSource = Nothing
CbbMunicipio.Text = ""
CbbLocalidad.Text = ""
CbbColonia.Text = ""
L_SQL = "SELECT * FROM MUNICIPIO (INDEX=IX_MUNICIPIO) WHERE
EDO_CLAVE =" & Trim(CbbEstado.SelectedValue())
SDAGral.SelectCommand.Connection = DB
SDAGral.SelectCommand.CommandText = L_SQL
SDAGral.Fill(DSMunicipio, "MUNICIPIO")
With CbbMunicipio
.ValueMember = "MUN_CLAVE"
.DisplayMember = "MUN_DESCRIPCION"
L_BANDERA_MUN = True
.DataSource = DSMunicipio.Tables("MUNICIPIO")
End With

End If
End Sub

Private Sub CbbMunicipio_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
CbbMunicipio.SelectedIndexChanged

If L_BANDERA_MUN = True Then

CbbLocalidad.DataSource = Nothing
CbbColonia.DataSource = Nothing
CbbLocalidad.Text = ""
CbbColonia.Text = ""
Dim DSLocalidad As New DataSet()
L_SQL = "SELECT * FROM LOCALIDAD (INDEX=IX_LOCALIDAD) WHERE
MUN_CLAVE =" & Trim(CbbMunicipio.SelectedValue())
SDAGral.SelectCommand.Connection = DB
SDAGral.SelectCommand.CommandText = L_SQL
SDAGral.Fill(DSLocalidad, "LOCALIDAD")
With CbbLocalidad
.ValueMember = "LOC_CLAVE"
.DisplayMember = "LOC_DESCRIPCION"
L_BANDERA_LOCALIDAD = True
.DataSource = DSLocalidad.Tables("LOCALIDAD")
End With
End If
End Sub
 

Leer las respuestas

#1 Jonapa
08/02/2005 - 21:49 | Informe spam
GRACIAS HTB LO VOY A PROBAR

Preguntas similares