Xbrowse con Columna CheckBox - (Solucionado)

Post Reply
User avatar
leandro
Posts: 958
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia
Contact:

Xbrowse con Columna CheckBox - (Solucionado)

Post by leandro »

Buenas noches a todo el foro:

Como dice el encabezado quiero colocar una columna con checkbox sobre una dbf, he leido muchos ejemplos en el foro pero todos estan sobre arrays
lo unico que encontre sobre una dbf es el siguiente codigo pero no logro hacerlo funcionar.

Code: Select all

FUNCTION pChebrowse()

local oDlg,oMvg1

DEFINE DIALOG oDlg NAME "orBuscar" ICON "#8001" TRANSPARENT

   REDEFINE BUTTONBMP Btn_Limp ID 4003 OF oDlg BITMAP "Blimpi2" TOOLTIP oLamcla:mTfil
   REDEFINE GET oBog1 VAR oMvg1 ID 4002 OF oDlg UPDATE

   REDEFINE SAY oSay ID 4004 PIXEL OF oDlg COLOR oLamcla:cClr5 PICTURE '@!'

   SELE d_ctasc
   dbappend()
   Dbgotop()
   oBrw := TXBrowse():New( oDlg )
   oBrw:nMarqueeStyle         := MARQSTYLE_HIGHLCELL //MARQSTYLE_HIGHLROW //
   oBrw:nColDividerStyle      := LINESTYLE_RAISED
   oBrw:nHeaderLines          := 1
   oBrw:lFooter               := .t.
   oBrw:nFooterLines          := 1
   oBrw:nFooterHeight         := 24
   oBrw:lColDividerComplete   := .t.
   oBrw:lRecordSelector       := .t.
   oBrw:bClrStd               := {|| IF( (Recno()%2)==0,{oLamcla:cClr5,oLamcla:cClr2},{oLamcla:cClr5,oLamcla:cClr1} ) }
   oBrw:bClrSel               := {|| { oLamcla:cClr5,oLamcla:cClr7 } }
   oBrw:bClrSelFocus          := {|| { CLR_WHITE,RGB(147,160,112) } }
   oBrw:lFastEdit             := .t.

       oCol  := oBrw:oCol( "Existe" )
       oCol:SetCheck( { "GREEN", "RED" }, {|o, v| (DBRLOCK(), d_ctasc->exist := v, DBUNLOCK() ) } )
       oCol:bStrData        := { || If( d_ctasc->exist, "Yes", "No" ) }
       oCol:nDataStrAlign   := AL_RIGHT

   oBrw:SetRDD()
   oBrw:CreateFromResource(102)


ACTIVATE DIALOG oDlg NOWAIT On Init (Centra( oDlg ),oDlg:refresh()) //VALID (pValCapSal(),.t.)
return nIL
 
Me dice que la función SetCheck no existe, alguien tiene un ejemplo...
Last edited by leandro on Fri Aug 23, 2013 11:21 pm, edited 1 time in total.
Saludos
LEANDRO ALFONSO
SISTEMAS LYMA - BASE
Bogotá (Colombia)
[ FWH 19.09 ] [ xHarbour 1.2.3 Intl. (SimpLex) (Build 20190613) ] [ Embarcadero C++ 7.30 for Win32 ]
User avatar
Armando
Posts: 2479
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Re: Xbrowse con Columna CheckBox

Post by Armando »

Leandro:

Va un ejemplo con recordset pero fácilmente lo puedes adaptar a DBFs cambiando
el origen de los datos

Code: Select all

            aCol[ 7]                            := oBrw:AddCol()
            aCol[ 7]:AddResource("SI16")
            aCol[ 7]:AddResource("NO16")
            aCol[ 7]:cHeader                := "Can"
            aCol[ 7]:bBmpData               := { || IF(oRsHdr:RecordCount() > 0,IIF(oRsHdr:Fields("HDR_CAN"):Value,1,2),2) }
            aCol[ 7]:nHeadBmpAlign      := AL_RIGHT
 
Saludos
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
leandro
Posts: 958
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia
Contact:

Re: Xbrowse con Columna CheckBox

Post by leandro »

Amigo buena noche, primero que todo muchas gracias por contestar.... Pero te cuento que adapte el código y no me funciono, así quedo:

Code: Select all

  oCol = oLamcla:oBrwCapt:AddCol()
   oCol:AddResource("BFLEC")
   oCol:AddResource("BEQUIS")
   oCol:cHeader      := "Activa"
   oCol:bBmpData            := { || IF(d_ctasc->exist,1,2) }
   oCol:nHeadBmpAlign      := AL_RIGHT
 
y esta es la imagen

Image

De Antemano Gracias
Saludos
LEANDRO ALFONSO
SISTEMAS LYMA - BASE
Bogotá (Colombia)
[ FWH 19.09 ] [ xHarbour 1.2.3 Intl. (SimpLex) (Build 20190613) ] [ Embarcadero C++ 7.30 for Win32 ]
vlmsoft
Posts: 36
Joined: Thu Jun 28, 2007 3:43 pm
Location: Madrid

Re: Xbrowse con Columna CheckBox

Post by vlmsoft »

Hola Leandro

.....

REDEFINE XBROWSE oBrw ;
   ALIAS "Cliente" ;
   FIELDS Cliente->Codigo , ;
              Cliente->Nombre , ;
              Cliente->Baja ;
   ID 101 ;
   OF oDlg

....

oBrw:aCols[3]:SetCheck( { "CHECKON","CHECKOFF" } )

*** CHECKON y CHECKOFF son dos bitmaps almacenados en un fichero de recursos


Un saludo
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Xbrowse con Columna CheckBox

Post by nageswaragunupudi »

Mr Leandro

oBrw:SetRDD() should immediately follow oBrw := TXBrowse():New(oDlg ).
Then you would not get this error.

As long as you use this syntax for creation of XBrowse, you are likely to get into some other other errors or unable to avail most features of Xbrowse.

We highly recommend using command syntax.

In your example:

Code: Select all

REDEFINE XBROWSE oBrw ID 102 OF oDlg ALIAS "d_ctasc" AUTOCOLS ;
   CELL LINES FOOTERS FASTEDIT

oBrw:oCol( "Exist" ):SetCheck( { "GREEN", "RED" }, .t. )

<other clauses>

ACTIVATE DIALOG oDlg ........... <other clauses>
 
The above code would have done what you wanted.
Regards

G. N. Rao.
Hyderabad, India
User avatar
leandro
Posts: 958
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia
Contact:

Re: Xbrowse con Columna CheckBox

Post by leandro »

Thanks for answering Mr. Nao and vlmsoft

But I get the following error

Code: Select all

Descripción del Error:
___________________________________________________

Error BASE/1004
Class: 'NIL' has no exported method: SETCHECK
   Args:
     [   1] = U
     [   2] = A   { ... }
     [   3] = L   .T.
 
so stay the code

Code: Select all

FUNCTION pChebrowse()

local oDlg,oMvg1

DEFINE DIALOG oDlg NAME "orBuscar" ICON "#8001" TRANSPARENT

   REDEFINE BUTTONBMP Btn_Limp ID 4003 OF oDlg BITMAP "Blimpi2" TOOLTIP oLamcla:mTfil
   REDEFINE GET oBog1 VAR oMvg1 ID 4002 OF oDlg UPDATE

   REDEFINE SAY oSay ID 4004 PIXEL OF oDlg COLOR oLamcla:cClr5 PICTURE '@!'

   SELE d_ctasc
   dbappend()

   Dbgotop()
   oBrw := TXBrowse():New( oDlg )


   REDEFINE XBROWSE oBrw ID 102 OF oDlg ALIAS "d_ctasc" AUTOCOLS ;
   CELL LINES FOOTERS FASTEDIT

   oBrw:oCol( "Cambia" ):SetCheck( { "GREEN", "RED" }, .t. )

   oBrw:SetRDD()


ACTIVATE DIALOG oDlg NOWAIT On Init (Centra( oDlg ),oDlg:refresh()) //VALID (pValCapSal(),.t.)
return nIL
 
Saludos
LEANDRO ALFONSO
SISTEMAS LYMA - BASE
Bogotá (Colombia)
[ FWH 19.09 ] [ xHarbour 1.2.3 Intl. (SimpLex) (Build 20190613) ] [ Embarcadero C++ 7.30 for Win32 ]
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Xbrowse con Columna CheckBox

Post by nageswaragunupudi »

What is the exact spelling of the field "Cambia" ?
If there is no field by name "cambia" you will get this error.
Please post dbstruct() of the dbf that is opened with the alias "d_ctasc"
Regards

G. N. Rao.
Hyderabad, India
User avatar
leandro
Posts: 958
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia
Contact:

Re: Xbrowse con Columna CheckBox

Post by leandro »

Mr. Nao Thank's for answer

The structure is as follow

Code: Select all

IF !FILE (".\dbfs\lamtem\ctas.DBF")
   DbCreate( ".\dbfs\lamtem\ctas",{   { "cuent"  ,"C",  10, 0 },;
                                                  { "nombr"  ,"C",  50, 0 },;
                                                  { "exist"    ,"L",   1,  0 } } )
ENDIF
 
"Cambia" = exist->d_ctasc
Saludos
LEANDRO ALFONSO
SISTEMAS LYMA - BASE
Bogotá (Colombia)
[ FWH 19.09 ] [ xHarbour 1.2.3 Intl. (SimpLex) (Build 20190613) ] [ Embarcadero C++ 7.30 for Win32 ]
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Xbrowse con Columna CheckBox

Post by nageswaragunupudi »

Code: Select all

   USE (".\dbfs\lamtem\ctas.DBF") NEW ALIAS SHARED d_ctasc

   < ... your other code ..>

   REDEFINE XBROWSE oBrw ID 102 OF oDlg ALIAS "d_ctasc"  ;
   COLUMNS "cuent", "nombre", "exist" ;
   CELL LINES FOOTERS FASTEDIT

   oBrw:oCol( "exist" ):SetCheck( { "GREEN", "RED" }, .t. )
 
You can refer to a column with oBrw:oCol( <cheader> ) OR oBrw:oCol( 3 ) ( creation order number. In the above case header of 3rd column is "exist" by default and not "Cambia"

If you specify different headers like this then you should use the header name

Code: Select all

   REDEFINE XBROWSE oBrw ID 102 OF oDlg ALIAS "d_ctasc"  ;
   COLUMNS "cuent", "nombre", "exist" ;
   HEADERS "Cuentxxx", "Nombrexxx", "Cambia" ;
   CELL LINES FOOTERS FASTEDIT

   oBrw:oCol( "Cambia" ):SetCheck( { "GREEN", "RED" }, .t. )
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
leandro
Posts: 958
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia
Contact:

Re: Xbrowse con Columna CheckBox

Post by leandro »

Mr NAO, muchas gracias por responder, al rato lo reviso y te comento.

Saludos
Saludos
LEANDRO ALFONSO
SISTEMAS LYMA - BASE
Bogotá (Colombia)
[ FWH 19.09 ] [ xHarbour 1.2.3 Intl. (SimpLex) (Build 20190613) ] [ Embarcadero C++ 7.30 for Win32 ]
User avatar
leandro
Posts: 958
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia
Contact:

Re: Xbrowse con Columna CheckBox

Post by leandro »

Thanks Mr. NAO, worked very well. :D
Saludos
LEANDRO ALFONSO
SISTEMAS LYMA - BASE
Bogotá (Colombia)
[ FWH 19.09 ] [ xHarbour 1.2.3 Intl. (SimpLex) (Build 20190613) ] [ Embarcadero C++ 7.30 for Win32 ]
Post Reply