Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
2 ListBox questions
Message
De
21/06/2014 05:10:53
 
 
À
20/06/2014 17:00:43
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01602159
Message ID:
01602165
Vues:
43
Question 1: yes. You must use a RowSourceType of 0, 1 or 5 (array) to disable items.

Question 2: normally, using \] instead of \ would be sufficient, but unfortunately this is bugged. To circumvent it, you to have to build your list with RowSourceType = 0, insert items using .AddItem() method and use \] prefix to prevent mouse and keyboard access in disabled items.


>I have a form with a list box. I want to disable some of the items in the listbox. So I put a backslash in the front of all the items I need to disable. My code looks something like
>SELECT somefield FROM sometable WHERE conditions INTO CURSOR somecursor READWRITE
>SCAN
>    IF disable_condition
>        REPLACE somefield WITH "\" + somefield
>    ENDIF
>ENDSCAN
>
>WITH myListBox
>    .RowSourceType = 2 && alias
>    .RowSource = "somecoursor"
>ENDWITH
>
>When the listbox displays, it shows the backslash in the item and none of the items are disabled.
>
>Question 1: Is this expected behavior when using an alias? If so, I didn't find it documented (although I could easily have missed it).
>
>Second Try - Using an array
>I added an array as a form property and modified the code to be
>SELECT somefield FROM sometable WHERE conditions INTO CURSOR somecursor READWRITE
>SCAN
>    IF disable_condition
>        REPLACE somefield WITH "\" + somefield
>    ENDIF
>ENDSCAN
>
>DIME thisform.aMyListBox[RECCOUNT("somecursor")]  && Copy to array only copies to the current length of the array
>COPY TO ARRAY thisform.aMyListBox
>WITH myListBox
>    .RowSourceType = 5 && array
>    .RowSource = "thisform.aMyListBox"
>ENDWITH
>
>Now all the items I want to be disabled show in the disabled color. If you double-click on a disabled item nothing will happen.
>
>But........If I click on an item and then use the arrow keys the disabled items are not bypassed. Pressing the Enter key while
>pointing to a disabled item will fire the DblClick code, allowing the user to get around the item being disabled.
>
>I can easily get around this
>**In ListBox DblClick code
>IF thisform.aMyListBox[this.ListIndex] = "\"
>    RETURN 0
>ENDIF
>
>.....rest of code
>
>but...
>
>Question 2: Is this correct behavior for disabled items in the sense that disabled is only supposed to apply to mouse clicks?
>
>Thanks...........Rich
----------------------------------
António Tavares Lopes
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform