Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

about the ensure visible method

Hi,

I have created a textbox .
In this textbox a user can keyboard a term that already exists in a listview just under the textbox.

If the user keyboards even a part of a term which already exists in the listview, the term is selected in the listview.

I wanted to use the ensurevisible method applicated to the listview, to permit an user to see the term selected , without using the scroll bar.

Here is the code i have used.I see the generation is not possible; it takes a long time and it stops.
Could you help me to solve my problems.

Thanks a lot.

Best regards.

Nathalie

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

Dim iTextLength As Integer = TextBox1.Text.Length
Dim iItemIndex As Integer
Dim index As Integer

Dim bFoundMatch As Boolean = False

While Not bFoundMatch And iTextLength > 0
index = 0
iItemIndex = 0
While Not bFoundMatch And iItemIndex < ListView1.Items.Count
If TextBox1.Text.TrimEnd.Length <= ListView1.Items(iItemIndex).Text.TrimEnd.Length Then
If TextBox1.Text.ToLower.TrimEnd = ListView1.Items(iItemIndex).Text.Substring(0, TextBox1.Text.TrimEnd.Length).ToLower Then
If iItemIndex > -1 Then
'appliquer la mthode de visualisation directe du terme slectionn dans la listview sans utiliser de scroll bar
ListView1.EnsureVisible(iItemIndex)

bFoundMatch = True

End If
End If
End If
iItemIndex += 1
End While

If (Not bFoundMatch) AndAlso (iTextLength > 1) Then
iTextLength -= 1
TextBox1.Text = TextBox1.Text.Substring(0, iTextLength)
End If
End While
End Sub
[2162 byte] By [harbonne] at [2007-11-11 8:00:25]