
23/02/2010, 16:20
|
| | Fecha de Ingreso: julio-2008
Mensajes: 52
Antigüedad: 16 años, 8 meses Puntos: 0 | |
Respuesta: problema con el selectedindexchanged hola muchas gracias por las respuestas:
ya he puesto try catch a todos los procedimientos de mi formulario pero aun asi
no se atrapa el error no se que esta pasando es un error que no se ha podido controlar me saca completamente de la aplicación
Aqui pongo el codigo de todo lo que hago con el combobox cbbApellidos
haber si alguien podria hecharme la mano en resolver esto
ya cambie el codigo y aun asi me sigue dando error
aqui hace la busqueda en la base de datos en el evento key press y muestra todas las posibles opciones de lo que se escribe dentro del combobox
Private Sub cbbApellidos_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles cbbApellidos.KeyPress
Try
Dim comando As New SqlCommand("Select Nombre_cliente,Apellidos_cliente from CLIENTES where Apellidos_cliente like '" & cbbApellidos.Text & "%'", conexion)
'Abrir_Conexion()
conexion.Open()
Dim lector As SqlDataReader = comando.ExecuteReader
Me.cbbApellidos.Items.Clear()
Me.cbbApellidos.DroppedDown = True
Try
Do While lector.Read
Me.cbbApellidos.Items.Add(lector("Apellidos_client e") & ", " & lector("Nombre_cliente"))
Loop
lector.Close()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "ERROR")
End Try
Cerrar_Conexion()
Me.cbbApellidos.SelectionStart = Len(cbbApellidos.Text)
Catch ex As Exception
MsgBox(Err.Description)
End Try
End Sub
EN ESTE PROCEDIMIENTO SOLO CAMBIO A MAYUSCULAS LO QUE ESCRIBO PORQUE NO ENCONTRE OTRA FORMA DE HACERLO EN TIEMPO DE DISEÑO
Private Sub cbbApellidos_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbbApellidos.TextChanged
Try
Dim I As Integer
Me.cbbApellidos.Text = UCase(Me.cbbApellidos.Text)
I = Len(cbbApellidos.Text)
Me.cbbApellidos.SelectionStart = I
Catch ex As Exception
MsgBox(Err.Description)
End Try
End sub
Y ESTE PROCEDIMIENTO ES PARA QUE ME MUESTRE LOS DATOS DE LA PERSONA QUE ESTOY BUSCANDO
Private Sub cbbApellidos_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbbApellidos.SelectedIndexChanged
Try
Dim x As Integer = Me.cbbApellidos.Text.IndexOf(",")
CargarDatos("Select * from CLIENTES")
If x >= 0 Then
Dim nombre, apellidos As String
apellidos = Me.cbbApellidos.Text.Substring(0, x).TrimEnd()
nombre = Me.cbbApellidos.Text.Substring(x + 1).TrimStart()
Filas = Tabla.Rows
Buscar_fila = Tabla.Select("Apellidos_cliente = '" & apellidos & "' AND Nombre_cliente = '" & nombre & "'")
If Buscar_fila.Length = 0 Then
MessageBox.Show("El Cliente que busca no Existe vuelva a introducir sus Apellidos", "Buscar")
Exit Sub
End If
Dim i, j, posi As Integer
For i = 0 To Buscar_fila.Length - 1 'Indica el tamaño del arreglo
For j = 0 To Filas.Count - 1
If (Filas(j).Equals(Buscar_fila(i))) Then
posi = j
Exit For
End If
Next
Next
BindingSource.Position = posi
Enlazar_Datos_Clientes()
End If
Catch ex As Exception
MsgBox(Err.Description)
End Try
End Sub
EL PROBLEMA SIGUE SIENDO CUANDO YO TECLEO EL APELLIDO Y NOMBRE DE UNA PERSONA QUE NO EXISTE EN LA BASE DE DATOS Y LE DOY ENTER NO SE PUEDE CONTROLAR EL ERROR SIGUIENTE: InvalidArgument=El valor de '0' no es válido para 'index'.
Nombre del parámetro: index
al marcar este error me saca completamente de la aplicacion y eso me da muchos problemas
alguien podria decirme como controlarlo o que esta mal en mi codigo??
muchas gracias por la ayuda |