Problemas con un ComboBox
Publicado por Miguel (281 intervenciones) el 14/01/2017 14:10:36
Tengo un formulario con un ComboBox. tengo dos campos del formulario que cada vez que entro en uno de ellos me carga un fichero de texto del que selecciono una opción del mismo. Entro en el primero y capturo el item que quiero. El problema que entro en el segundo campo y me coge los valores del fichero txt anterior.
Les dejo el código pues yo estoy desmoralizado ya que no doy con el problema.
Espero que alguien pueda indicarme el error.
Gracias y un saludo
Les dejo el código pues yo estoy desmoralizado ya que no doy con el problema.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Private Sub txtEstado_GotFocus(sender As Object, e As EventArgs) Handles txtEstado.GotFocus
Dim miFichero As String = "C:\Ficheros\Estado.txt"
Me.ClientSize = New System.Drawing.Size(950, 640)
Me.cbDatos.Items().Clear()
cargacbBox(miFichero)
End Sub
Private Sub txtEsposo_GotFocus(sender As Object, e As EventArgs) Handles txtEsposo.GotFocus
Dim miFichero As String = "C:\Ficheros\Relacion.txt"
Me.ClientSize = New System.Drawing.Size(950, 640)
Me.cbDatos.Items().Clear()
cargacbBox(miFichero)
End Sub
Private Sub cargacbBox(ByVal miFichero As String)
Dim sLine As String = ""
Dim objReader As New StreamReader(miFichero)
If My.Computer.FileSystem.FileExists(miFichero) Then
Select Case miFichero
Case "C:\Ficheros\Estado.txt"
miNume = 1
Case "C:\Ficheros\Relacion.txt"
miNume = 2
End Select
Do
sLine = objReader.ReadLine()
If Not sLine Is Nothing Then
cbDatos.Items.Add(sLine)
End If
Loop Until sLine Is Nothing
objReader.Close()
Else
MsgBox("File not found.")
End If
End Sub
Private Sub cbDatos_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbDatos.SelectedIndexChanged
Select Case miNume
Case 1
txtEstado.Text = cbDatos.SelectedItem.ToString
txtEsposo.Focus()
Case 2
txtEsposo.Text = cbDatos.SelectedItem.ToString
txtHijos.Focus()
End Select
Me.ClientSize = New System.Drawing.Size(735, 640)
End Sub
Espero que alguien pueda indicarme el error.
Gracias y un saludo
Valora esta pregunta


0