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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Color to a ListBox

Status
Not open for further replies.

ggrewe

IS-IT--Management
Jul 10, 2001
169
US
In VFP 9 is it possible to change the color of the text in a listbox dynamically? Sort of like DynamicBackColor in a grid.

Basically I want to change the text color list item if a particular value is true.

I have tried the following to no avail;

Code:
FOR i = 1 TO .lstAttendeeName.ListCount
	IF !EMPTY(.lstAttendeeName.List[i,5])
		THISFORM.lstAttendeeName.List[i].ItemForeColor = "RGB(128,255,128)"
	ENDIF
ENDFOR



Greg Grewe
West Chester, Ohio
 

Greg,

No, you can't address the individual list items in that way.

The closest you can get to it is to use the DEFINE POPUP command to create a popup, with whatever colours you like for the items. Then create your listbox, set its RowSourceType to 9, and its RowSource to the name of the popup.

However, that approach is very limited, and in any case I don't think it meets your main requirement, which is change the colour of a row dynamically. But it might be worth exploring.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Thanks Mike, I appreciate your feedback. If I try that, I will let you know. Have a good week.



Greg Grewe
West Chester, Ohio
 

Greg,

Another possibility would be disable the items that you want to show in a different colour. Then set the listbox's DisabledItemForeColor and DisabledItemBackColor to the colours you want.

The trouble with that is that the user won't be able to select the coloured items.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
Thanks Mike, I did try this over the weekend and though it did work, you are right, the user could not select the disabled item. I may just use a grid and remove the grid lines instead. Should work the same way. Thanks again!



Greg Grewe
West Chester, Ohio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top