Page loading

Share your opinion
What do you think about gambaslinux.fr?
 
Interesting
It miss some informations
Excellent website
Results
WIDGETS GAMBAS
GAMBAS 3 SOFTWARES
TUTORIALS
Library
LISTVIEW - Select an item
SELECTIONNER UN ITEM DANS UNE LISTVIEW

liste.png

Ajourd'hui nous allons voir comment sélectionner un item dans une listbox ou une listview.

CREATION DE L'INTERFACE
creer deux textbox, creer une listbox et une listview.
Maintenant ajoutons ce code pour l'evènement KEYPRESS des deux textbox :

PUBLIC SUB TextBox1_KeyRelease()
DIM i AS Integer
DIM a AS String


'pour trouver un nom dans la liste en tapant la ou les premières lettres
   IF ListBox1.List.Count = 0 THEN RETURN


 FOR i = 0 TO ListBox1.List.Count

  ListBox1.Index = i
    IF InStr(Left(UCase(ListBox1.Text), Len(TextBox1.Text)), UCase(TextBox1.Text)) <> 0 THEN
    A = ListBox1.text
         RETURN
     ELSE
    A = ""   
    END IF
  NEXT

END

PUBLIC SUB TextBox2_KeyRelease()
'pour trouver un nom dans la listeview en tapant la ou les premières lettres

  IF ListView1.MoveFirst() THEN RETURN

  REPEAT

    IF InStr(Left(UCase(ListView1.Item.Text), Len(TextBox2.Text)), UCase(TextBox2.Text)) <> 0 THEN
    ListView1[ListView1.Item.Key].Selected = TRUE

        BREAK
    END IF
  UNTIL ListView1.MoveNext()
END

Essayez l'exmple. Lors d'une saisie d'une lettre, l'item sélectionné se déplace automatiquement.
Une différence cependant. Dans la listbox, si vous saisissez une lettre et que vous l'effacez, l'item se désélectionne, et ceci pas dans la listview.
A Bientôt
Merci taotebluetongue

Creation date : 17/09/2009 @ 17:54
Last update : 17/09/2009 @ 17:55
Category : LISTVIEW
Page read 5804 times


Print the article Print the article


react.gifReactions to this article

Nobody gave a comment yet.
Be the first one to do it!


QUICK MENU
SEARCH




LANGUAGE
COMPONENTS
Other
LANGUAGE
Where, who?
VISITS

   visitors

   visitors online

ARCHIVES GAMBAS 1/2
^ Top ^