Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Selected Item in a Listbox store item number to form val
Message
De
07/04/2004 11:16:41
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
07/04/2004 11:10:21
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00892932
Message ID:
00892940
Vues:
14
:) Happens to all of us. You might even shorten the code :
*--cmdAdd Button click
*--Adds an item selected in lstSource listbox to lstSelected listbox
THISFORM.LockScreen = .T. && Is this really needed - not sure when it's not grid :)
with THIS.parent.lstSource
 if .ListIndex > 0
   THIS.Parent.lstSelected.AddItem(.List(.ListIndex))
   .RemoveItem(.ListIndex)
 ENDIF
endwith
THISFORM.LockScreen = .F.
Cetin


>This is too cool Cetin! It works great. Now I can select an item in the left listbox and copy it to the right listbox and there is not delay because I am not stepping through the listbox to determine which item is selected. Can't believe I forgot about listindex! Haven't used it in months....THANKS!
>
>
>
>*--cmdAdd Button click
>*--Adds an item selected in lstSource listbox to lstSelected listbox
>THISFORM.LockScreen = .T.
>nCnt = THIS.parent.lstSource.ListIndex
>IF THIS.Parent.lstSource.Selected(nCnt)
>   THIS.Parent.lstSelected.AddItem(THIS.Parent.lstSource.List(nCnt))
>   THIS.Parent.lstSource.RemoveItem(nCnt)
>ENDIF
>THISFORM.LockScreen = .F.
>
>
>>>When I click on an item in a listbox to select it, I am storing the value in the listbox to a variable. I would also like to store the listbox item number to a form property to determine which item was selected instead of stepping through the listbox as it is now (see code below). In other words, I do not allow multiselect on the listbox and I want to know what the 'nCnt' (see nCnt var below) value is when I click on an item. Is there anyway to determine that?
>>>
>>>
>>>nCnt = 1
>>>DO WHILE nCnt <= THIS.Parent.lstSource.ListCount
>>>   IF THIS.Parent.lstSource.Selected(nCnt)
>>>      THIS.Parent.lstSelected.AddItem(THIS.Parent.lstSource.List(nCnt))
>>>      THIS.Parent.lstSource.RemoveItem(nCnt)
>>>   ENDIF
>>>ENDDO
>>>
>>
>>Directly use ListIndex.
>>Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform