StrataFrame Forum

listview ( refresh)

http://forum.strataframe.net/Topic30984.aspx

By Eric Leissler - 2/25/2012

hi,

how can i do ?

in a form, i have a listview and a textbox.

The listview is on a businessobject client

i want in the validated method of the textbox make

If Bo_clients1.Seek("raison_sociale = '" & Me.Tbox2.Text.Trim & "'") = True Then

Me.ListView1.Requery()

 

End If

after the requery, i woud have the listview1 on the current reccord

 

Thanks for your answer

Best regards

Eric

 

By Edhy Rijo - 2/25/2012

Hi Eric,

If I understand you correctly, you have a textbox and when the user enter a value you want to show that record selected in the listview, right?

If so, you don't have to requery the listview, you have to loop the listview items until you find the correct record, then select it.  Here is some code I use in one of my applications that may be what you are looking for:

 Dim findTextValue As String = txtFindCustomerName.Text.ToUpper
         If String.IsNullOrEmpty(findTextValue) Then
             Exit Sub
         End If
         With Me.lstQBCustomers
             For Each item As StrataListViewItem In .Items
                 If item.SubItems(1).Text.ToUpper.StartsWith(findTextValue) Then
                     item.Selected = True
                     .EnsureVisible(item)
                     Exit Sub
                 End If
             Next
         End With


Keep in mind that in the above code I am using a StrataListView, so the item is cast as StrataLisviewItem, if you are using the standard SF ListView, then I believe it should be cast to a ListViewItem, also I am specifically comparing the Text value of a SubItem(1), in your case you have to make sure which column value in your listview will be used to locate the searched text.  Since you are first locating the record in your Client1 bo via the Seek() method, I would use the Client1 PK, and search the ListViewItem.Tag instead.
By Michel Levy - 2/25/2012

Eric,

une variante de la solution d'Edhy Rijo (merci Edhy)
a similar way as the solution provided by Edhy Rijo (Thanks Edhy)



Private Sub txtSaisie_TextChanged(sender As System.Object, e As System.EventArgsHandles txtSaisie.TextChanged
    Dim maSaisie As String = Me.txtSaisie.Text.ToUpper
    Me.lstModePaie.FindItemWithText(maSaisie).Selected = True
    If Not IsNothing(Me.lstModePaie.SelectedItems(0)) Then
        Me.lstModePaie.SelectedItems(0).EnsureVisible()
    End If
End Sub
By Edhy Rijo - 2/25/2012

Hi Michael,

Thanks for pointing out the FindItemWithText(), I used it before, but after replacing my SF ListView controls with the StrataListView I had to go with the items collection loop since the method FindItemWithText() does not exist in the StrataListView yet Crying
By Eric Leissler - 2/25/2012

many thank's Edhy

best regards

Eric
By Edhy Rijo - 2/27/2012

You are welcome Eric.  Glad it help out.