Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/06/2011, 15:05
future89
 
Fecha de Ingreso: diciembre-2010
Mensajes: 106
Antigüedad: 13 años, 4 meses
Puntos: 10
Pregunta como agregar otra fila listview

hola .
es un sistema de ventas de libro y necesito ingresar varios libros en un listview uno por uno mediante un textbox evento keyPress y solo puedo ingresar uno solo y al querer incresar otro nopasa nada ...

este es el codigo

Código vb:
Ver original
  1. Private Sub TbProducto_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TbProducto.KeyPress
  2. 'Valido que se ingrese solo numeros
  3.  
  4.         If Char.IsNumber(e.KeyChar) Then
  5.             e.Handled = False
  6.             'Valido que se presione Backspace,Enter
  7.        ElseIf Char.IsControl(e.KeyChar) Then
  8.             e.Handled = False
  9.             'Las demas teclas quedan bloqueadas
  10.        Else
  11.             e.Handled = True
  12.         End If
  13.  
  14.         'Si mando un ENTER entonces que busque
  15.        If e.KeyChar = Convert.ToChar(Keys.Enter) Then
  16.  
  17.            
  18.             myConn = New SqlConnection("Initial Catalog=libroteka;Data Source=localhost;Integrated Security=SSPI;")
  19.             'Crear un objeto Command.
  20.            myCmd = myConn.CreateCommand
  21.             myCmd.CommandText = "SELECT * FROM libros WHERE cod_libro ='" & TbProducto.Text & "' "
  22.  
  23.            
  24.             adaptor.SelectCommand = myCmd
  25.             adaptor.Fill(dataset, "0")
  26.  
  27.             Dim count = dataset.Tables(0).Rows.Count
  28.             If count > 0 Then
  29.  
  30.                 myConn.Open()
  31.                 With Ltver.Items.Add(TbProducto.Text, "cod_libro")
  32.                     .SubItems.Add(dataset.Tables(0).Rows(0).Item("nombre_libro"))
  33.                     .SubItems.Add(dataset.Tables(0).Rows(0).Item("precio"))
  34.  
  35.                  
  36.                 End With
  37.  
  38.  
  39.             End If
  40.  
  41.  
  42.  
  43.             TbProducto.Clear()
  44.             dataset.Clear()
  45.             myConn.Close()
  46.         End If

y es el texbox le digo que al ingresar 13 digitos me lanse un Enter

Código vb:
Ver original
  1. Private Sub TbProducto_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TbProducto.TextChanged
  2.  
  3.         'Si llega a 13
  4.        If TbProducto.Text.Trim().Length = 1 Then
  5.             'Que envie un enter
  6.            SendKeys.Send("{Enter}")
  7.         End If
  8.  
  9.     End Sub