FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Add a Checkbox() column
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Add a Checkbox() column
Posted: Sun Nov 19, 2023 09:16 AM
Hi,

There is xBrowse(). At some point I need to add a Checkbox() column to it.
However, it does not work. Tell me what I'm wrong about ?
Code (fw): Select all Collapse
oDlg:oClient:aCols[2]:bClrBtn:=&('{||{'+ltrim(str(CLR_BLACK))+','+ltrim(str(CLR_WHITE))+'}}')
 oDlg:oClient:aCols[2]:cHeader:=""
 oDlg:oClient:aCols[2]:SetCheck(, .T.)
 oDlg:oClient:aCols[2]:nWidth:=20
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Add a Checkbox() column
Posted: Sun Nov 19, 2023 09:37 AM
Marc Venken

Using: FWH 23.08 with Harbour
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Add a Checkbox() column
Posted: Sun Nov 19, 2023 10:14 AM

I was asking about adding a checkbox column to a working browser, not about creating a browser with such a column

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Add a Checkbox() column
Posted: Sun Nov 19, 2023 03:47 PM

First you need to add a column with all logical values.

Then Set oCol:SetCheck(,.T. )

Regards



G. N. Rao.

Hyderabad, India
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Add a Checkbox() column
Posted: Sun Nov 19, 2023 05:32 PM
Instead of setcheck(, .T.), I used the icons and everything worked fine
Code (fw): Select all Collapse
  oDlg:oClient:aCols[2]:lBmpTransparent:= .T.
        oDlg:oClient:aCols[2]:AddBitmap( { "p_chk1", "p_chk2" } )
        oDlg:oClient:aCols[2]:bBmpData:={||iif(oDlg:oClient:aRow[2],2,1)}
        oDlg:oClient:aCols[2]:bStrData:=NIL
        oDlg:oClient:aCols[2]:bLDClickData:={||oDlg:oClient:aRow[2]:=! oDlg:oClient:aRow[2]})
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Add a Checkbox() column
Posted: Sun Nov 19, 2023 05:40 PM
5 lines of the code above can be reduced to a single line
Code (fw): Select all Collapse
oBrw:aCols[2]:SetCheck( { "p_chk1", "p_chk2" }, .T. )
Regards



G. N. Rao.

Hyderabad, India
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: Add a Checkbox() column
Posted: Sun Nov 19, 2023 05:42 PM

Thank you, Rao! Very elegant.

Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Add a Checkbox() column
Posted: Mon Dec 11, 2023 12:17 PM

I have a xbrowse of a dbf table, this is a table created specifically to make selections.

In the last column I want to show a logical field that permit to select some of the record that I see in ths xbrowse

for instance this is the penultimane columnt is define in this way

oCol = oBrw:AddCol()

oCol:bStrData = { || TRANSFORM( field->imp_eff, "@ZE 999,999,999.99" ) }

oCol:cHeader = "TOTALE CLIENTE"

oCol:nEditType = EDIT_NONE

oCol:nWidth = 100

oCol:nDataStrAlign := AL_RIGHT

How can I add another column that read / edit the value of field->seleziona Logical type?

I want to see the classic two bitmap CHECKON and CHECKOFF

many thanks

Marco Boschi
info@marcoboschi.it
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Add a Checkbox() column
Posted: Tue Dec 12, 2023 04:39 AM
Code (fw): Select all Collapse
WITH OBJECT oBrw:AddCol()
   :bEditValue := { |x| If( x == nil, (oBrw:cAlias)->SELEZIONA, (oBrw:cAlias)->SELEZIONA := x ) }
   :SetCheck( nil, .t. )  // uses default bitmaps
   // OR to use your own bitmaps
   :SetCheck( { <bmpOn>, <bmpOff> }, .t. )
END
<bmpOn>, <bmpOff> can be names of any bmp or any image files or resource names.
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion