Different colored text in a list box in FPW26 
Author Message
 Different colored text in a list box in FPW26

I have a question that I'm not even sure if it's possible in FoxPro 2.6 for
Windows. I have a list box that I'm listing an array in. What I would like to
be able to do is have the elements of the array print in different colors.
Depending on the array element, they would be in red, blue or black. I would
appreciate if someone could tell me how this can be done, or if it's even
possible, or if there's another suggestion of how I can accomplish this.

If anybody has any suggestions or comments about this, even if it's just to say

Thanks

Doug



Wed, 29 Mar 2000 03:00:00 GMT  
 Different colored text in a list box in FPW26

No.  A listbox is an individual object.  The elements of the listbox are
a single entity.  You might want to put quotes, asteriks, dashes, etc
around the data to highlight the fields...different colors...no.

Quote:

> I have a question that I'm not even sure if it's possible in FoxPro
> 2.6 for
> Windows. I have a list box that I'm listing an array in. What I would
> like to
> be able to do is have the elements of the array print in different
> colors.
> Depending on the array element, they would be in red, blue or black. I
> would
> appreciate if someone could tell me how this can be done, or if it's
> even
> possible, or if there's another suggestion of how I can accomplish
> this.

> If anybody has any suggestions or comments about this, even if it's
> just to say
> that it can't be done, I'd appreciate an e-mail at

> Thanks

> Doug



Thu, 30 Mar 2000 03:00:00 GMT  
 Different colored text in a list box in FPW26

Quote:

> I have a question that I'm not even sure if it's possible in FoxPro 2.6 for
> Windows. I have a list box that I'm listing an array in. What I would like to
> be able to do is have the elements of the array print in different colors.
> Depending on the array element, they would be in red, blue or black. I would
> appreciate if someone could tell me how this can be done, or if it's even
> possible, or if there's another suggestion of how I can accomplish this.

> If anybody has any suggestions or comments about this, even if it's just to say

> Thanks

> Doug

Can do easy.  Define a popup, with each row in the popup taking on a
color based upon your defined criteria (I have included some of my code
below).  Then in the listbox, set 'List Items' from the popup (in my
case, COLORS).

*-  Text Colors
gray_var="128,128,128,255,255,255"
blue_var="0,0,255,255,255,255"
purple_var="255,0,255,255,255,255"
red_var="255,0,0,255,255,255"
black_var="0,0,0,255,255,255"

*-  Highlight Colors
hgray_var="192,192,192,128,128,128"
hblue_var="0,0,255,128,128,128"
hpurple_va="128,0,128,128,128,128"
hred_var="128,0,0,128,128,128"
hblack_var="255,255,255,128,128,128"

DEFINE POPUP COLORS FROM 1,1 SCROLL
ON SELECTION POPUP COLORS DEACTIVATE POPUP COLORS

IF NOT USED('EQUIP')
        USE EQUIP IN 82 ORDER CRCAT SHARE
ENDIF

SELECT EQUIP

SET FILTER TO UTC=m.utc

*-  Database is open and filter is set, so count records
COUNT TO num_items

IF num_items=0

        *-  No items

        DEFINE BAR 1 OF COLORS PROMPT " "
        DEFINE BAR 2 OF COLORS PROMPT " "
        DEFINE BAR 3 OF COLORS PROMPT " "
        DEFINE BAR 4 OF COLORS PROMPT "               " ;
                + "***   There are NO Equipment Items Listed   ***"
        DEFINE BAR 5 OF COLORS PROMPT " "
        DEFINE BAR 6 OF COLORS PROMPT "               " ;
                + "***  in the JOPES TUCHA Data for this Unit  ***"

        equip_var=0

ELSE

        DIMENSION equip_array (num_items,12)
        COPY TO ARRAY equip_array

        GOTO TOP
        FOR ib=1 TO num_items

                cargo_var=SUBSTR(equip_array(ib,2),2,1)

                DO CASE

                        *-  Non-air
                        CASE cargo_var="0"

                                txt_clr="red_var"

                        *-  Outsize
                        CASE cargo_var="1"

                                txt_clr="purple_var"

                        *-  Oversize
                        CASE cargo_var="2"

                                txt_clr="blue_var"

                        *-  Bulk
                        CASE cargo_var="3"

                                txt_clr="gray_var"

                        OTHERWISE

                                txt_clr="black_var"

                ENDCASE

                htxt_clr = "h" + txt_clr
                txt_clr  = &txt_clr
                htxt_clr = &htxt_clr

                DEFINE BAR ib OF COLORS PROMPT " " ;
                        + equip_array(ib,5) ;
                        + STR(equip_array(ib,6),6) ;
                        + STR(equip_array(ib,7),7) ;
                        + STR(equip_array(ib,8),7) ;
                        + STR(equip_array(ib,9),7) ;
                        + STR(equip_array(ib,11),8,1) ;
                        + STR(equip_array(ib,12),9,1) ;
                        + STR(equip_array(ib,10),5) ;
                        COLOR ,RGB(&txt_clr),,,,RGB(&htxt_clr)

                SKIP

        ENDFOR

ENDIF



Fri, 31 Mar 2000 03:00:00 GMT  
 Different colored text in a list box in FPW26

Quote:
>Can do easy.  Define a popup, with each row in the popup taking on a
>color based upon your defined criteria (I have included some of my code
>below).  Then in the listbox, set 'List Items' from the popup (in my
>case, COLORS).

Neat trick, Mark, and it works with a rowsourcetype = 9 in a VFP listbox too
<s>...

For some reason I couldn't get your color assignments to work as in your
samples in VFP, so (JIC anybody else gets discouraged) this is what did work
(very small adjustment):

htxt_clr  = eval("h"+txt_clr)
txt_clr = eval(txt_clr)
txt_clr = "rgb("+txt_clr+")"
htxt_clr = "rgb("+htxt_clr+")"

DEFINE BAR ib OF COLORS PROMPT " " ....
COLOR ,&txt_clr.,,,,&htxt_clr.

... I have no idea why this would be any different, maybe there was just a
typo in what you u/l'd... anyway, it's a great idea, thanks for sharing with
everybody!

Quote:
>L<



Wed, 12 Apr 2000 03:00:00 GMT  
 Different colored text in a list box in FPW26

Quote:
>Can do easy.  Define a popup, with each row in the popup taking on a
>color based upon your defined criteria (I have included some of my code
>below).  Then in the listbox, set 'List Items' from the popup (in my
>case, COLORS).

Neat trick, Mark, and it works with a rowsourcetype = 9 in a VFP listbox too
<s>...

For some reason I couldn't get your color assignments to work as in your
samples in VFP, so (JIC anybody else gets discouraged) this is what did work
(very small adjustment):

htxt_clr  = eval("h"+txt_clr)
txt_clr = eval(txt_clr)
txt_clr = "rgb("+txt_clr+")"
htxt_clr = "rgb("+htxt_clr+")"

DEFINE BAR ib OF COLORS PROMPT " " ....
COLOR ,&txt_clr.,,,,&htxt_clr.

.. I have no idea why this would be any different, maybe there was just a
typo in what you u/l'd... anyway, it's a great idea, thanks for sharing with
everybody!

Quote:
>L<



Wed, 12 Apr 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Changing colors in list box for different records

2. List or combo boxes - different controls?

3. different colors on different rows in a report

4. Refresh text box after selecting a different grid record

5. List Box Color Question

6. Changing Colors in a list box

7. Color control for listbox and text box

8. Color Highlighting terms in a text box

9. list box 2 based on list box 1

10. fpw26 List Box

11. Utility to convert 2 digit year text boxes into 4 year digit text boxes

12. List Box question in FPW26

 

 
Powered by phpBB® Forum Software