Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

3 state check box or alternative

Status
Not open for further replies.

megmogg

Programmer
Jul 14, 2005
76
GB

Hi all

I have a field in a local cursor that is either T, F, or NULL.

In my grid, I want the user to be able to use a control that gives them the 3 states.

Tried checkboxes with no sucess. Combo Box, but cannot convert from TEXT to LOGICAL.

Any ideas?

Thanks
 
Add a form property, say cValue.

In the INIT of the form assign a value of "T", ie THISFORM.cValue = "T"

Add your checkbox.

In the VALID of the checkbox add:

Code:
WITH THISFORM

	IF .lValue = "T"
		THIS.VALUE = .NULL.
		.lValue = "N"
	ELSE
		IF .lValue = "N"
			THIS.VALUE = .F.
			.lValue = "F"
		ELSE
			IF .lValue = "F"
				THIS.VALUE = .T.
				.lValue = "T"
			ENDIF
		ENDIF
	ENDIF

	.REFRESH()

ENDWITH

You should then get 3 states of the checkbox - blank (.F.), greyed and ticked, or the themed equivalent if appropriate (.NULL.) or ticked (.T.).

You would then obviously need to handle the propetry if its to populate a field.

Neil


I like work. It fascinates me. I can sit and look at it for hours...
 


Thanks for the quick reply

Will try it out.

Just also playing around with converting the .T., .F. and NULL into string values for a drop-down combo box as well.

Cheers
 
Well, a checkbox is able to show .null., but if you click it, it will only switch fbetwenn .t. to .f., never return to .null. or 2.

Neil has shown you a way. Even if you keep the native checkbox a user can enter .null. by just having it in focus and pressing CTRL+0. By the way this is also possible with other controls. Beware, that not nullable fields will throw errors when set to null. You normally turn this feature off with ON KEY LABEL CTRL+0 * to prevent bad things happening.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top