Add a Checkbox() column

Add a Checkbox() column

Postby Natter » Sun Nov 19, 2023 9: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: Select all  Expand view
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
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am

Re: Add a Checkbox() column

Postby Marc Venken » Sun Nov 19, 2023 9:37 am

Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1434
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Add a Checkbox() column

Postby Natter » 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
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am

Re: Add a Checkbox() column

Postby nageswaragunupudi » Sun Nov 19, 2023 3:47 pm

First you need to add a column with all logical values.
Then Set oCol:SetCheck(,.T. )
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Add a Checkbox() column

Postby Natter » Sun Nov 19, 2023 5:32 pm

Instead of setcheck(, .T.), I used the icons and everything worked fine

Code: Select all  Expand view
 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]})
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am

Re: Add a Checkbox() column

Postby nageswaragunupudi » Sun Nov 19, 2023 5:40 pm

5 lines of the code above can be reduced to a single line
Code: Select all  Expand view
oBrw:aCols[2]:SetCheck( { "p_chk1", "p_chk2" }, .T. )
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Add a Checkbox() column

Postby Natter » Sun Nov 19, 2023 5:42 pm

Thank you, Rao! Very elegant.
Natter
 
Posts: 1221
Joined: Mon May 14, 2007 9:49 am

Re: Add a Checkbox() column

Postby MarcoBoschi » 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
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Add a Checkbox() column

Postby nageswaragunupudi » Tue Dec 12, 2023 4:39 am

Code: Select all  Expand view
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
User avatar
nageswaragunupudi
 
Posts: 10643
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 68 guests