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!

coloring text in a list box or a listview control

Status
Not open for further replies.

fenris

Programmer
May 20, 1999
824
CA
How would I go about colorizing specific text in a listbox, listview control or even a text box or a label.

For example Say I have the following data in a listview control:

1 2 3 4 5 6
4 5 65 43 23 35
3 7 14 56 25 15

And I want to display the numbers that are evenly divisble by 5 in red (5,65,35,25....) How would I do this with out disturbing the rest of the data? Can I use html tags or something simple like that or would this be more in depth?

Any help is greatly appreciated
Troy

Troy Williams B.Eng.
fenris@hotmail.com

 

Textboxes and Listviews have a ForeColor property. Search the help for forecolor and you'll see how to use them.

Text1.Forecolor = number
or
Text1.Forecolor = RGB(x,y,z)

x=amount of RED
y=amount of GREEN
z=amount of BLUE



Tarek

The more I learn, the more I need to learn!
 
i think this will not work... The forecolor will change the hole color of your list.. I don't know the way to do such a thing with Visual Basic.. there is no control I know doing that,, but i know that the forecolor pro. will not do it..

 
As far as I can see, the Listbox control has not properties you can use for this.

Maybe you could achieve the effect you want by:
* using the MSFlexGrid control, which allows you to set the ForeColor and BackColor of each cell.
* writing suitable code for the MSFlexGrid control's Click and / or DoubleClick event.

 
I think you could only use the rich text box to do that.

David Paulson


 
The RTF control works pretty well. With a nudge in the right direction, you can even use it as scrollable menu list(HTML style).
VCA.gif
 
Thanks for the input. I appreciate it.
I have discovered the forecolor property of the controls but I haven't had time to investigate them. If as some comments stated that it is not possible to do what I want with these controls, then I will check out the rich text box and see what I can do with that.
thanks

Troy Williams B.Eng.
fenris@hotmail.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top