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

Colors in the lines of LisBox

Status
Not open for further replies.

vitorsa

Programmer
Apr 28, 2000
13
0
0
PT
Does anyone know how to have diferent color for lines in a ListBox?<br><br>Please!!!<br><br>Thanks.
 
Vitorsa,<br>&nbsp;&nbsp;there are ways of achieving this. By preceding your list item with the \, the item is considered disabled in the listbox. However, this is not entirely true because although it appears disabled, the user can select it as if it werent disabled(this is a major VFP flaw in my opinion). There are two properties: disableditembackcolor and disableditemforecolor you can use to differentiate the enabled from the disabled ones, thus giving you the appearance of different colored lines. As an example, paste this code into the init event of a listbox named list1 and run the form. You will see items with alternated blue and white background colors.<br><br>WITH ThisForm.List1<br>&nbsp;&nbsp;.disableditembackcolor = rgb(0,0,255)<br>&nbsp;&nbsp;.disableditemforecolor = rgb(255,255,255)<br>&nbsp;&nbsp;.additem('\This is item one')<br>&nbsp;&nbsp;.additem('This is item two')<br>&nbsp;&nbsp;.additem('\This is item three')<br>&nbsp;&nbsp;.additem('This is item four')<br>ENDWITH<br><br>Jon Hawkins<br><A HREF="mailto:jonscott8@yahoo.com">jonscott8@yahoo.com</A>
 
Coloring separate items within listboxes and comboboxes<br><br>It's a dead-simple trick: you use a RowSourceType of 9 (popup). You can define a popup with each bar showing in different colors (and you can re-define bars as necessary). Below is a little simple, runnable code so you can see the effect. <br>* The first section of code merely enables you to <br>* run this code multiple times,<br>* so you can see the effect in both baseclasses:<br>if type(&quot;_screen.y.baseclass&quot;) = &quot;C&quot;<br>&nbsp;&nbsp;&nbsp;if upper(_screen.y.baseclass) = &quot;LISTBOX&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myclass = &quot;combobox&quot;<br>&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myclass = &quot;listbox&quot;<br>&nbsp;&nbsp;&nbsp;endif<br>&nbsp;&nbsp;&nbsp;_screen.removeobject(&quot;y&quot;)<br>else<br>&nbsp;&nbsp;&nbsp;myclass = &quot;listbox&quot;<br>endif&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br>* This middle section of code defines the popup<br>* we'll use as rowsource, so you<br>* can see the color-handling syntax.<br>* Please note the *comma* in the color clauses below<br>* -- we need to change the contents of <br>* the *second color pair* for each bar as needed:<br>define popup x<br>define bar 1 of x prompt &quot;red on white&quot; ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;color ,rgb(255,0,0,255,255,255)<br>define bar 2 of x prompt &quot;not touched&quot;<br>define bar 3 of x prompt &quot;red also&quot; ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;color ,rgb(255,0,0,255,255,255)<br>define bar 4 of x prompt &quot;not touched&quot;<br>define bar 5 of x prompt &quot;purple on green&quot; ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;color ,rgb(255,0,255,125,255,0)<br>define bar 6 of x prompt &quot;blue on yellow&quot; ;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;color , rgb(0,0,255,255,255,0)<br><br>* And now to see the popup as a rowsource:<br>_screen.addobject(&quot;y&quot;,myclass)<br>with _screen.y<br>&nbsp;&nbsp;.rowsourcetype = 9<br>&nbsp;&nbsp;.rowsource = &quot;x&quot;<br>&nbsp;&nbsp;.visible = .t.<br>endwith&nbsp;&nbsp;<br>You'll note that the documentation specifies RowSourceType of 9 as &quot;for backward compatibility only&quot;. Well, this seems like a waste of perfectly useful feature to me. If anybody else can create the same effect without a RowSourceType of 9, I'll be willing to believe the docs. <br><br>* repliers note:&nbsp;&nbsp;OMG, I wish I was that smart.&nbsp;&nbsp;That was from Lisa Slater Nichols website.&nbsp;&nbsp;<br><br>JohnDurbin<br>
 
There was a ActiveX Listbox that allows colors, etc added to UT recently.&nbsp;&nbsp;I'm gonna check it out and I'll let you know.&nbsp;&nbsp;That will be in my opinion the easiest way to go.&nbsp;&nbsp;(If it works)<br>JDurbin
 
JDurbin -

Did you find an ActiveX listbox that allows for easy color manipulation?

Thanks
Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top