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
> .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 thisform.aMyListBox
>WITH myListBox
> .RowSourceType = 5
> .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