Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

looking for workaround re bug in listbox

Status
Not open for further replies.

Nifrabar

Programmer
Mar 16, 2003
1,343
NL
Hi!
The listbox is having a bug.
Disabled items cannot be selected with mouse.
Using keyboard you can!

Is there a known workaround?

I tried in interactivechange method:
if this.enabled = .F.
keyboard "{MOUSE}"
endif
but without result
my philosophy was :
if item is disabled than simulate a mouseclick ( keyboard "{MOUSE}") as with a real mouseclick it is not possible to select a disables item.

any suggestions?
-Bart
 
first this.enabled is only determining the enabled status of the whole listbox. As in any method of a control, THIS is the control, not this item.

On the other side you're right, this bug exists and there is a workaround by using AddItem, see here:

Bye, Olaf.
 
Olaf,

Thanks for pointing me to the workaround.
Going to see how I can adapt this solution.

-Bart
 
Olaf,
I used the workaround and it does as expected (with one column in use)
Now I added a 2nd column. The only way I could achieve this was with AddListItem()
Code:
select "view4"
GO top

FOR i = 1 TO lnRows
	thisform.bvs_lst3.AddItem[(view4.kenmerk),i,1]
	thisform.bvs_lst3.AddlistItem[TRANSFORM(view4.nkenm_ID),i,2]
	SKIP
ENDFOR

That made available the 2nd column.
Than I wanted to give the disabled items a different color.
For test I did :
thisform.bvs_lst3.disableditemBackColor=rgb(255,0,0)
With only one column did works. With the 2nd column added it fails.
Should this be another bug? Or do I oversee some?

-Bart
 
In the first place, the workaround is not only to use AddItem(), but also precede the items with "\]" to mark them as disabled. Did you read through the link I pointed you to? Did you add the prefix into the kenmerk field?

In regard to seconadary columns I think you better go over to a grid instead, if that's what you need, listbox features like disabled items and itemtip only work with a single column.

In a grid you have much better control. Add a column with a selection checkbox and disable that for disabled items. Coloring is possible per column etc.

Use a grid for more complex lists.

Bye, Olaf.
 
I seem to remember a similar problem some years ago. If memory serves, I solved it by adding "\]" to the values in both the columns. I think there was a discussion of it here on Tek Tips, and I also wrote it up as a tip for FoxPro Advisor. (But it was a very long time ago.)

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Mike,

I referenced And it tells to
1. use Additem() (instead of a alias rowsource or soomthing else)
2. preceed each item with "\]", not only "\" to also disable selection by keyboard (!)

I still say Bart should think about using a grid instead to gain more control on enabling/disabling and coloring.

Bye, Olaf.
 
Olaf,

I'm with you that grid gives in many situations more flexbility.
Nevertheless I now have the listbox in a newly created mover-class which does what must be done.
If I could do a multiselect I probably should go to grid.

Mike,
Good brains ..;-) thread of 5 years ago!
Anyway it solved my problem.

Thanks again to both of you for taking the time to help!!

-Bart

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top