FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Celda Colores Xbrowse
Posts: 537
Joined: Mon Jan 16, 2006 03:42 PM
Celda Colores Xbrowse
Posted: Sat Apr 18, 2026 01:02 AM

amigos como puedo hacer esto:

Saludos

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Celda Colores Xbrowse
Posted: Sat Apr 18, 2026 03:56 AM

Prueba asi:

#include "FiveWin.ch"  

#include "XBrowse.ch"  
  

static aDatos  
  

function Main()  
  

   local oWnd, oBrw, oFont, n  
  

   // Array de datos: cada fila = { cCombinazione, nBa, nCa, nFl, nGe, nMi, nNa, nPa, nRo, nTo, nVe, nNz }  

   aDatos := { ;  

      { "90 01 02 03 04 05 06 07 08 09",  45,  29,  97, 472, 265, 127,   3, 123,  24,  11,  55 }, ;  

      { "10 11 12 13 14 15 16 17 18 19",  66, 104, 298,  79,  47,  12,  12,  90,  48, 130, 155 }, ;  

      { "20 21 22 23 24 25 26 27 28 29", 158,   7,   7,  95, 169,  86, 230, 148,  79, 446,  20 }, ;  

      { "30 31 32 33 34 35 36 37 38 39",  11,  17, 131, 422,  50, 204,  37,   5,  11,  48, 433 }, ;  

      { "40 41 42 43 44 45 46 47 48 49",  52,   8,  49, 312,  58, 128, 108, 284, 248,  92, 373 }, ;  

      { "50 51 52 53 54 55 56 57 58 59",  33,  30, 440, 451,  77,  60,  70, 227, 440,  31,  25 }, ;  

      { "60 61 62 63 64 65 66 67 68 69",  70, 134,   5,  60,  55,  11, 347,  22,  28, 549,  66 }, ;  

      { "70 71 72 73 74 75 76 77 78 79", 259,  58,  30,  18,  57,  91,  27, 126,  65,  78, 176 }, ;  

      { "80 81 82 83 84 85 86 87 88 89", 107,  42, 118,  94,  37,  49,  23, 623,  22,  19,  79 }  ;  

   }  
  

   DEFINE FONT oFont NAME "Tahoma" SIZE 0,-13  

   DEFINE WINDOW oWnd TITLE "DATI ELABORATI 6505 CONCORSI" FONT oFont  
  

   @ 0, 0 XBROWSE oBrw ;  

      DATASOURCE aDatos ;  

      COLUMNS 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ;  

      HEADERS "Combinazione", "Ba", "Ca", "Fl", "Ge", "Mi", "Na", "Pa", "Ro", "To", "Ve", "Nz" ;  

      COLSIZES 200, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50 ;  

      LINES CELL OF oWnd  
  

   WITH OBJECT oBrw  

      :lRecordSelector  := .F.  

      :lHScroll         := .F.  

      :nRowHeight       := 22  

      :nDataStrAligns   := AL_RIGHT  

      :nMarqueeStyle    := MARQSTYLE_HIGHLROW  
  

  // Columna 1 (Combinazione) sin color especial  
  :aCols[ 1 ]:nDataStrAlign := AL_LEFT  
  :aCols[ 1 ]:bClrStd := { || { CLR_BLACK, CLR_WHITE } }  
  
  // Asignar colores condicionales a las columnas de datos (2..12)  
  for n := 2 to 12  
     :aCols[ n ]:bClrStd := ColorBlock( n )  
  next  
  
  :CreateFromCode()  
   END  
  

   oWnd:oClient := oBrw  
  

   ACTIVATE WINDOW oWnd ON INIT oBrw:SetFocus()  
  

   RELEASE FONT oFont  
  

return nil  
  

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

// Genera un bloque de color condicional para cada columna  

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

static function ColorBlock( nCol )  
  

return < |oBrw, oCol|  

   local nVal  := oBrw:aRow[ nCol ]  

   local nClrBack  
  

   // Ajusta estos rangos segun tu logica de colores  

   do case  

      case nVal <= 20  

         nClrBack := CLR_RED            // Rojo para valores muy bajos  

      case nVal <= 50  

         nClrBack := CLR_BLUE           // Azul para valores bajos  

      case nVal <= 100  

         nClrBack := CLR_YELLOW         // Amarillo para valores medios  

      case nVal <= 200  

         nClrBack := RGB( 0, 200, 0 )   // Verde para valores altos  

      otherwise  

         nClrBack := CLR_HGRAY          // Gris para valores muy altos  

   endcase  
  

   return { CLR_BLACK, nClrBack }  

  

//----------------------------------------------------------------------------//
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1279
Joined: Mon Feb 06, 2006 04:28 PM
Re: Celda Colores Xbrowse
Posted: Sat Apr 18, 2026 01:07 PM

Prueba así:

#include "Fivewin.ch"
#include "WinApi.ch"
#include "xBrowse.ch"

static aDatos

function Main()

   local oWnd, oBrw, n, oFont

DEFINE FONT oFont NAME "Tahoma" SIZE 0,-13

   // Array de datos
   aDatos := { ;
      { "90 01 02 03 04 05 06 07 08 09",  45,  29,  97, 472, 265, 127,   3, 123,  24,  11,  55 }, ;
      { "10 11 12 13 14 15 16 17 18 19",  66, 104, 298,  79,  47,  12,  12,  90,  48, 130, 155 }, ;
      { "20 21 22 23 24 25 26 27 28 29", 158,   7,   7,  95, 169,  86, 230, 148,  79, 446,  20 }, ;
      { "30 31 32 33 34 35 36 37 38 39",  11,  17, 131, 422,  50, 204,  37,   5,  11,  48, 433 }, ;
      { "40 41 42 43 44 45 46 47 48 49",  52,   8,  49, 312,  58, 128, 108, 284, 248,  92, 373 }, ;
      { "50 51 52 53 54 55 56 57 58 59",  33,  30, 440, 451,  77,  60,  70, 227, 440,  31,  25 }, ;
      { "60 61 62 63 64 65 66 67 68 69",  70, 134,   5,  60,  55,  11, 347,  22,  28, 549,  66 }, ;
      { "70 71 72 73 74 75 76 77 78 79", 259,  58,  30,  18,  57,  91,  27, 126,  65,  78, 176 }, ;
      { "80 81 82 83 84 85 86 87 88 89", 107,  42, 118,  94,  37,  49,  23, 623,  22,  19,  79 }  ;
   }

   DEFINE WINDOW oWnd TITLE "DATI ELABORATI 6505 CONCORSI" 

   @ 0, 0 XBROWSE oBrw ;
      DATASOURCE aDatos ;
      COLUMNS 1,2,3,4,5,6,7,8,9,10,11,12 ;
      HEADERS "Combinazione","Ba","Ca","Fl","Ge","Mi","Na","Pa","Ro","To","Ve","Nz" ;
      COLSIZES 200,50,50,50,50,50,50,50,50,50,50,50 ;
      LINES CELL OF oWnd FONT oFont

   WITH OBJECT oBrw

  :lRecordSelector := .F.
  :lHScroll        := .F.
  :nRowHeight      := 22
  :nDataStrAligns  := AL_RIGHT
  :nMarqueeStyle   := MARQSTYLE_HIGHLROW

  // Columna 1 (texto)
  :aCols[1]:nDataStrAlign := AL_LEFT
  :aCols[1]:bClrStd := { || { CLR_BLACK, CLR_WHITE } }

  // Columnas con color condicional
  for n := 2 to 12

     :aCols[n]:bClrStd := { |oBrw, oCol|
        local nVal := oBrw:aRow[ oCol:nCreationOrder ]
        local nClr

        do case
           case nVal <= 20
              nClr := CLR_RED
           case nVal <= 50
              nClr := CLR_BLUE
           case nVal <= 100
              nClr := CLR_YELLOW
           case nVal <= 200
              nClr := RGB( 0, 200, 0 )
           otherwise
              nClr := CLR_HGRAY
        endcase

        return { CLR_BLACK, nClr }
     }

  next

  :CreateFromCode()

   END

   oWnd:oClient := oBrw

   ACTIVATE WINDOW oWnd ON INIT oBrw:SetFocus()

return nil
Saludos/Regards,

José Murugosa

"Los errores en programación, siempre están entre la silla, el teclado y la IA!!"
Posts: 537
Joined: Mon Jan 16, 2006 03:42 PM
Re: Celda Colores Xbrowse
Posted: Mon Apr 20, 2026 03:18 PM

Muchas Gracias

Continue the discussion