Hola, en un listbox no lo se pero un GRID si.
Te paso el trozo de código que desarrollo el compañero MUSTAFA lo hace genial.
Imagino que copiando la parte que te interesa lo tendrás.
Code: Select all
fColor := { || if ( This.CellRowIndex/2 == int(This.CellRowIndex/2) , BLUE , RED ) }
bcolor := { || if ( This.CellRowIndex/2 = int (This.CellRowIndex/2) , {180,200,255} , {255,255,211} ) }
*-----------------------------------------------------------------------------------------------------------*
*----------------------------------------------- Color Barra Video Inversa ---------------------------------*
_HMG_SYSDATA [ 348 ] := { 199,250,225 }
_HMG_SYSDATA [ 349 ] := { 007,071,041 }
_HMG_SYSDATA [ 350 ] := { 235,237,095 }
_HMG_SYSDATA [ 351 ] := { 069,015,135 }
*-----------------------------------------------------------------------------------------------------------*
SELECT 1
USE STOCK INDEX STOCK
DEFINE GRID Grid_1
ROW 070
COL 030
WIDTH 700
HEIGHT 379
HEADERS { '','Ref','Producto','Tipo','Precio','C_Barras' }
WIDTHS { 17, 122 , 149 , 135 , 116 , 138 }
VALUE 0
IMAGE { 'Resource\02x.bmp','Resource\01x.bmp' }
JUSTIFY { GRID_JTFY_LEFT, GRID_JTFY_RIGHT, GRID_JTFY_LEFT , GRID_JTFY_LEFT, GRID_JTFY_RIGHT, GRID_JTFY_LEFT}
DYNAMICFORECOLOR { fColor , fColor, fColor , fColor, fColor, fColor }
DYNAMICBACKCOLOR { bColor , bColor, bColor , bColor, bColor, bColor }
BACKCOLOR { 209,238,238 }
FONTCOLOR { 000,255,020 }
ONCHANGE ( SelecDes() , PositionData() )
MULTISELECT .F.
SHOWHEADERS .T.
ROWSOURCE "STOCK"
COLUMNFIELDS { 'IIF(STOCK->L,1,0)','STOCK->REF','STOCK->PRODUCTO','STOCK->TIPO','TRAN(STOCK->PRECIO, "@E 9,999,999.99")','STOCK->CBARRAS' }
FONTNAME 'Arial' // <----to show a dot instead a comma ---> //
FONTSIZE 9
CELLNAVIGATION .T.
END GRID