Listbox Colors

Post Reply
User avatar
Greg Gammon
Posts: 105
Joined: Fri Jun 09, 2006 3:27 pm
Location: Bryan, Texas

Listbox Colors

Post by Greg Gammon »

Is it possible to make individual rows of a Listbox different colors dependent on the data for that row???

Thanks,
G
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Greg,

I assume you mean a browse:

oBrw:nClrPane := { || If( OrdKeyNo() % 2 == 0, RGB( 230, 230, 230), RGB( 190, 215, 190 ) ) }
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Greg Gammon
Posts: 105
Joined: Fri Jun 09, 2006 3:27 pm
Location: Bryan, Texas

Post by Greg Gammon »

perfect...thanks! (how come I could not find "nclrpane" in the documentation for WBrowse??)
G
User avatar
Greg Gammon
Posts: 105
Joined: Fri Jun 09, 2006 3:27 pm
Location: Bryan, Texas

however....new one

Post by Greg Gammon »

Here's another problem I need to figure out...

How can I do nclrpane evaluating on different fields? i.e. I want to highlight in red for lcust = .t. and blue for cSales = "B" etc. In essence evaluating as if it were a DO CASE?

I might also be able to change text color in addition to background....is that nclrtext?

Thanks in advance....when you are a "weekend warrior" programmer, things get very rusty very quickly!
User avatar
Greg Gammon
Posts: 105
Joined: Fri Jun 09, 2006 3:27 pm
Location: Bryan, Texas

Treport also...

Post by Greg Gammon »

Should have just included this with previous post, but I need to do similar on my reports.... I would like to change the font, text color, or background on one row of the report based on the data....
Thanks!
G
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Greg,

> how come I could not find "nclrpane" in the documentation for WBrowse??

Class TWBrowse inherits from Class TControl which inherits from Class TWindow. Class TWindow implements DATA nClrPane, and its explained for that class. Though the issue of changing colors in a browse rows is a specific browse "trick"

If you use Class TWBrowse, then you can just use one color for an entire row. nClrText is the equivalent for nClrPane, but for the text color, so you can do it the same way.

You can change the font of the entire browse. Not just for some rows, or columns.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Post by Rick Lipkin »

Greg

Here is a snipit of code I use for turning rows different colors based on a fields condition per record ..

Rick Lipkin
SC Dept of Health, USA

//--------------------------------------

....

REDEFINE LISTBOX oBrow FIELDS ;
ALIAS xALIAS ;
ID 111 of oEMP ;
ON DBLCLICK ( _PtrpBrow( CTOD("00/00/00"), A->VNUMBER, A->LICENSE ),;
_ReFrsh( A->VNUMBER, dDATE1 ), ;
oBROW:REFRESH(), SysReFresh(),;
oBROW:SetFocus() ) ;
UPDATE

oBROW:nClrText := ;
{ || SelColor( A->MILEAGE, A->NEXTMILAGE,"F" ) }
oBROW:nClrPane := ;
{ || SelColor( A->MILEAGE, A->NEXTMILAGE,"B" ) }
oBROW:nClrForeFocus := ;
{ || SelColor( A->MILEAGE, A->NEXTMILAGE,"F" ) }

.....

//------------------------------
Static Func SelColor( nMILE,nMILE1,cTYPE )

LOCAL nCOLOR := CLR_BLACK

DO CASE
CASE cTYPE = 'F'

IF nMILE >= nMILE1 .and. nMILE1 <> 0
nCOLOR := CLR_WHITE
ELSE
nCOLOR := CLR_BLACK
ENDIF

CASE cTYPE = 'B'

DO CASE
CASE nMILE >= nMILE1 .and. nMILE1 <> 0
nCOLOR := RGB(192,3,51) // red

CASE ((nMILE1-nMILE) <= 500) .and. nMILE1 <> 0
nCOLOR := RGB(255,255,0) // yellow

OTHERWISE
nCOLOR := CLR_WHITE
ENDCASE

ENDCASE

RETURN( nCOLOR )
User avatar
Greg Gammon
Posts: 105
Joined: Fri Jun 09, 2006 3:27 pm
Location: Bryan, Texas

Post by Greg Gammon »

Rick,
Just saw this reply post....

So are you successful with having multiple colors on a browse? i.e. one line red, the next blue, the next green etc based on the data?

G
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Greg,

Do keep in mind that there are a lot of colorblind users. They may not be able to tell the difference in your colors. To check there is a colorblind simulator website. You take a screenshot and send it to their site and they display how it would look for each type of colorblindness.

http://www.aspnetresources.com/tools/co ... dness.aspx

It helps if you can use icons in addition, or in place of, color.

James
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Post by Rick Lipkin »

Greg

The code snipit is from our Vehicle reservation ( system ) listbox. We have over 700 cars in our Agency and from an internal audit .. we had to make sure the program areas keep track of their scheduled maint and oil changes.

Since most of the people who check out vehicles ( make reservations ) are just administrative staff .. I had to put some color in their face and the yellow line represents a vehicle that is within 500 miles of service and a red line is a vehicle that has gone past its scheduled PM.

Color coding certain rows based on specific data has been a stunning success.

Just keep it simple and not too colorful and like James mentions .. special attention to colors that may cause confusion with color blind people.

Rick Lipkin
User avatar
Greg Gammon
Posts: 105
Joined: Fri Jun 09, 2006 3:27 pm
Location: Bryan, Texas

Post by Greg Gammon »

Rick....
Nice! Thanks for sharing that. Exactly what I need!
In my particular application (commercial printer), we have a press schedule screen and I need to highlight those jobs requiring press checks, those that have firm due dates, and those that have special priority....while all the info is available textually, nothing says it like "in your face" color. I was able to implement a color change for background, and a text color change to handle two of the factors, and this has been quite successful (as far as making people aware of the information)...keeping a simple color structure is essential yes...so implementing your design will allow me to add that third criteria by changing the background color to a 2nd or 3rd color....thanks again.
G
User avatar
Greg Gammon
Posts: 105
Joined: Fri Jun 09, 2006 3:27 pm
Location: Bryan, Texas

Post by Greg Gammon »

Rick....one other thing....I have a question floating in a separate post (Multiple Browses) that James is helping me with regarding blanking out the highlight on the selected record. Since I am using color backgrounds on certain rows, when I have a row that is selected but not in the focused browse, it shows as gray, hiding the selected color....do you deal with that in any way? (i.e. I would like to elminate the windows highlight of the selected row so it doesn't hide the custom color).
G
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Greg,

>I would like to elminate the windows highlight of the selected row so it doesn't hide the custom color).

This is a good time to use icons as they will not be hidden. You can use icons and color if you wish, but don't make it too "busy."

As I said you can't eliminate the highlight when the browse is not in focus without changing the source. The color is hardcoded.

James
Post Reply