updating checkboxes?

updating checkboxes?

Postby deanomeano » Tue Feb 14, 2006 10:46 am

I am using several checkboxes in my program, and when I declare them i call a function for each one so that if one is ticked, if the user selects a different one then the focus will be changed and the first checkbox they selected will become blank.

CODE;

REDEFINE CHECKBOX oRubble VAR mRubble ID 104 OF oDlg VALID RubbleVal()
REDEFINE CHECKBOX oHardboard VAR mHardboard ID 105 OF oDlg VALID HardboardVal()
REDEFINE CHECKBOX oTreated VAR mTreated ID 106 OF oDlg VALID TreatedVal()
REDEFINE CHECKBOX oFerrous VAR mFerrous ID 107 OF oDlg VALID FerrousVal()
REDEFINE CHECKBOX oOrganic VAR mOrganic ID 108 OF oDlg VALID OrganicVal()

However, when testing this, I notice that I can still select multiple checkboxes and nothing is updated. here is the code I am using for the val functions i am calling in the VALIDS.

CODE;

STATIC FUNCTION RubbleVal

IF mRubble
mHardboard := .F.
mTreated := .F.
mFerrous := .F.
mOrganic := .F.

oHarboard:Refresh()
oTreated:Refresh()
oFerrous:Refresh()
oOrganic:Refresh()
ENDIF

RETURN .T.

STATIC FUNCTION HardboardVal

IF mHardboard
mRubble := .F.
mTreated := .F.
mFerrous := .F.
mOrganic := .F.

oRubble:Refresh()
oTreated:Refresh()
oFerrous:Refresh()
oOrganic:Refresh()
ENDIF

RETURN .T.

STATIC FUNCTION TreatedVal

IF mTreated
mRubble := .F.
mHardboard := .F.
mFerrous := .F.
mOrganic := .F.

oRubble:Refresh()
oHardboard:Refresh()
oFerrous:Refresh()
oOrganic:Refresh()
ENDIF

RETURN .T.

STATIC FUNCTION FerrousVal

IF mFerrous
mRubble := .F.
mHardboard := .F.
mTreated := .F.
mOrganic := .F.

oRubble:Refresh()
oHardBoard:Refresh()
oTreated:Refresh()
oOrganic:Refresh()
ENDIF

RETURN .T.

STATIC FUNCTION OrganicVal

IF mOrganic
mRubble := .F.
mHardboard := .F.
mTreated := .F.
mFerrous := .F.

oRubble:Refresh()
oHardboard:Refresh()
oTreated:Refresh()
oFerrous:Refresh()
ENDIF

RETURN .T.

Is what I am trying to do possible with checkboxes, or am I wasting my time with them. I know I could use radiobuttons but if I could get this to work in the same way that would be preferable.

Thanks for any comments or advice.
deanomeano
 
Posts: 22
Joined: Wed Nov 09, 2005 9:43 am

Re: updating checkboxes?

Postby Enrico Maria Giordano » Tue Feb 14, 2006 11:05 am

Use radiobuttons instead of checkboxes for mutually exclusive options.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby deanomeano » Tue Feb 14, 2006 11:14 am

Enrico,

As I said in my post, I know I can use radio buttons for this, but I would like that to be a last resort. Is what I am trying to do possible, if not then I shall rethink.

Thank You for your comments.
deanomeano
 
Posts: 22
Joined: Wed Nov 09, 2005 9:43 am

Postby deanomeano » Tue Feb 14, 2006 11:28 am

Enrico,

It is possible to do this with checkboxes, I have replaced VALID with ON CLICK and works fine.

Thanks for your comments.
deanomeano
 
Posts: 22
Joined: Wed Nov 09, 2005 9:43 am

Postby Enrico Maria Giordano » Tue Feb 14, 2006 11:35 am

deanomeano wrote:Enrico,

It is possible to do this with checkboxes, I have replaced VALID with ON CLICK and works fine.

Thanks for your comments.


Ok, but I still think that you should use radiobuttons.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby James Bott » Tue Feb 14, 2006 6:59 pm

As Enrico stated, you should use radio buttons for this. What you are doing is not standard windows behavior and thus not what the users will expect. It will just confuse them.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby manuramos » Tue Feb 14, 2006 7:34 pm

Try this

REDEFINE CHECKBOX aCHK[1] VAR aVar[1] ID 171 OF oDlg ON CLICK CompChek(aCHK,aVar,1)
REDEFINE CHECKBOX aCHK[2] VAR aVar[2] ID 172 OF oDlg ON CLICK CompChek(aCHK,aVar,2)
...
REDEFINE CHECKBOX aCHK[n] VAR aVar[n] ID 1nn OF oDlg ON CLICK CompChek(aCHK,aVar,n)

FUNCTION CompChek(aChk,aVar,nDat)
*
AFILL(aVar,.F.) // you could replace this 2 lines with your own conditions
aVar[nDat] := .T.
*
AEVAL(aChk, { |oCtrl| oCtrl:Refresh() }
RETURN NIL

You must build your CHEKBOXES with arrays. It runs like radiobuttons.
Nos Gusta Programar
manuramos
 
Posts: 219
Joined: Mon Dec 26, 2005 7:25 pm
Location: Jerez de la Frontera (Spain)

Postby deanomeano » Wed Feb 15, 2006 2:50 pm

manuramos, thank you for your help, although I found a solution to the problem.

James, yes I agree that radio buttons are more user friendly, but that is what the user of the system has asked for, that is why I said that ideally I would like to have used them instead of radio buttons.

Thank you for commenting
deanomeano
 
Posts: 22
Joined: Wed Nov 09, 2005 9:43 am

Postby James Bott » Wed Feb 15, 2006 5:02 pm

but that is what the user of the system has asked for


Ah, yes of course, you must do what the customer wants.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 72 guests