Sorry for my English
I need to add the function to be marked EnsureVisible row in the listview
Module load ListView
Code:Public Sub CargarListView_Cliente(LV_Cliente As ListView, rs As ADODB.Recordset) On Error GoTo ErrorSub LV_Cliente.ListItems.Clear If rs.RecordCount > 0 Then While Not rs.EOF Set objItem = LV_Cliente.ListItems.Add(, , rs(0)) objItem.SubItems(1) = rs!name objItem.SubItems(2) = rs!age objItem.SubItems(3) = rs!address rs.MoveNext Wend End If Exit Sub ErrorSub: If Err.Number = 94 Then Resume Next End Sub
Form1
Form2Code:Private Sub Form_Load() CargarListView_Cliente LV_Cliente, rs End Sub Private Sub LV_Cliente_DblClick() Dim i As Integer With form2 .IdCliente = LV_Cliente.SelectedItem.Text For i = 1 To 3 .Text1(i).Text = LV_Cliente.SelectedItem.ListSubItems(i).Text Next .Show vbModal End With End Sub
Code:Public IdCliente Private Sub cmdSave_Click() On Error GoTo ErrorSub cnn.Execute "UPDATE cliente set name = '" & Trim(Text1(1)) & _ "', age = '" & Trim(Text1(2)) & _ "', address = '" & Trim(Text1(3)) & _ "' where id_cliente = " & IdCliente & "" rs.Requery 1 Call CargarListView_Cliente(Form1.LV_Cliente, rs) DoEvents Unload Me Set Form2 = Nothing Exit Sub ErrorSub: MsgBox Err.Description End Sub
Any ideas to add functions
'LV_Cliente.ListItems.EnsureVisible
'LV_Cliente.ListItems.Selected = True




Reply With Quote