Ver Mensaje Individual
  #4 (permalink)  
Antiguo 17/01/2009, 08:11
kadosh
 
Fecha de Ingreso: enero-2009
Mensajes: 14
Antigüedad: 15 años, 3 meses
Puntos: 0
Respuesta: Ayuda con Listview

Hola , no se si entendi bien, pero creo que es asi, vos tenes los datos en un listviewcargados y queres guardarlos ?
tenes ( si es asi ) varios temas. si tenes mas de un row o fila, que decirle cual es la que queres guardar. segundo cual campo a cual de la db
lo primero es seleccionarlo, por ejemplo con un click, y que te selecciones la linea completa( es solo visual mas que nada ) y luego decirle que el indice es el que vas a selecccionar
por jemplo , algo rapidito seria :

Private Sub ListViewMESAS_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim item As ListItem
On Error GoTo ERRORES

Set item = Me.ListViewMESAS.HitTest(x, y)

If Not item Is Nothing And Button = vbRightButton Then
item.Selected = True (bueno , aca te selecciona la fila)
End If

Exit Sub
ERRORES:
ManejaErrores Err.Number, Me.Name & " CON " & Err.Description

y luego :

Private Sub ListViewMESAS_DblClick()
On Error GoTo ERRORES

Me.TextMesa.Text = ""

' verifica que hay datos en el ListView y que hay uno seleccionado
If (Me.ListViewMESAS.ListItems.Count = 0) Then
MiMsgBox " INFORMACION SOBRE ERRORES DEL SISTEMA ", "No hay ningún regisro para visuaizar ! Realice una nueva accion", , ERROR
Exit Sub
End If
If (Me.ListViewMESAS.SelectedItem Is Nothing) Then
MiMsgBox " INFORMACION SOBRE ERRORES DEL SISTEMA ", "Debe seleccionar previamente un registro para poder visualizarlo", , ERROR
Exit Sub
End If

If Len(Me.ListViewMESAS.SelectedItem) > 1 Then
If Mid(Me.ListViewMESAS.SelectedItem, 1, 1) = 0 Then
Me.TextMesa.Text = Mid(Me.ListViewMESAS.SelectedItem, 2)
Else
Me.TextMesa.Text = Me.ListViewMESAS.SelectedItem
End If

End If
Me.TextMesa.Text = Me.ListViewMESAS.SelectedItem
Me.TextMesa.SetFocus
SendKeys "{home}+{end}"
SendKeys "{enter}"
TextMesa_DblClick
Exit Sub
ERRORES:
ManejaErrores Err.Number, Me.Name & " CON " & Err.Description

End Sub

EN RESUMEN, LV.SELECTEDITEM ES LA FILA Y SI LE PONES PUNTO, TE DESPLIEGA LAS ENTRE OTROS SUBITEMS(O) ES EL PRIMERO DE LOS CAMPOS DE LA LISTVIEW Y (1) EL QUE LE SIGUE ... LO QUE NO SE SI ES QUE QUERES GUARDAR EN LA BASE DE DATOS LOS REGISTROS ES ASI A LA INVERSA, YO CARGO DESDE LA BASE DE DATOS ASI. Y LA LLENO A LA LISTA , SI ES AL REVES TOMAS EL RS=objitem.SubItems(1) SINO ..

Set objitem = LV.ListItems.Add(, , RS(0))
objitem.SubItems(1) = RS!usuario
objitem.SubItems(2) = RS!activo
objitem.SubItems(3) = RS!Salida_ok
objitem.SubItems(4) = RS!bloqueado
objitem.SubItems(5) = RS!escribe_mjs
objitem.SubItems(6) = RS!PC_UTILIZA
objitem.SubItems(7) = RS!acceso
RS.MoveNext
ESPERO TE SIRVA, Y SI NO Y ENTENDI MAL ESCRIBI AL PEDO UN MONTON JEJEJE


>
>
>

Cita:
Iniciado por SoloVisual Ver Mensaje
Buenas tardes
Estoy creando un base de datos en Visual Basic 6 (utilizo referencia DAO 2,5/3.51) y no encuentro código para guardar la información contenida en un listview con 2 columnas que se llaman "Patologia" y "Observación" y la tabla se llama tPacientes
la rutina para guardar comienza asi:

Private Sub cmGuardar_Click()
tPacientes.Index = ("índice")
tPacientes.Seek "=", Label1
If Not tPacientes.NoMatch Then
MsgBox "Ya existe una Historia con este registro", vbInformation, "Guardar"
Exit Sub

Else

tPacientes.AddNew
tPacientes("Registro") = Label1
tPacientes("Fecha") = Date

'Aqui debo escribir código para guardar el contenido del Listview que previamente se ha llenado con un Combobox

tPacientes.Update
End sub


Gracias de antemano