Data Access Worldwide Knowledge Base

Article ID 2334
Article Title HOWTO: Create a TriState Checkbox
Article URL http://www.dataaccess.com/kbasepublic/KBPrint.asp?ArticleID=2334
KBase Category VDF12
Date Created 07/26/2007
Last Edit Date 07/27/2007


Article Text
QUESTION:
I have the need for a tri-state checkbox in my applications. How do I create this?

ANSWER:
DataFlex has no built-in support for tri-state checkboxes but it is quite easy to make one. The enclosed class (cTriStateBox) supports 3 states (CHECKED, UNCHECKED and INDETERMINATE). You can add the class to your workspace or library and register it in your Visual DataFlex 12 classlist. By doing the latter, you can drag and drop the class from the palette to a component. At designtime the tristate box shows as a checkbox.

With this class you can create code like:

    Object oTriStateBox is a cTristateBox
        Set Location to 16 14
        Set Label to "Voila"
        Set CurrentStatus To BST_INDETERMINATE
    End_Object

And you can either directly change the current status or send NextStatus. This circles through the 3 states. It is also sent by clicking with the mouse on the box or its label or by pressing the space bar.

The label can be placed on the right hand side of the box (default) or on the left hand side. This setting is a designtime setting only.

    Object oTriStateBox is a cTristateBox
        Set Location to 16 14
        Set Label to "Voila"
        Set CurrentStatus To BST_INDETERMINATE
        Set piAlignmentMode to taLeftJustify
    End_Object

When the state of the box changes an OnChange event message is sent. Do NOT change the state inside this method!



Contributed By:
Vincent Oorsprong
Company: Data Access Worldwide
email: vincent.oorsprong@dataaccess.eu
Web Site: http://www.dataaccess.eu

Web Links Related to this Article
File cTriStateBox.pkg
URL=http://www.dataaccess.com/KBasePublic/Files/2334.cTriStateBox.pkg


Email this Article
Email this Article to a Colleague
Send Feedback on this Article to Data Access Worldwide
Copyright ©2010 Data Access Corporation. All rights reserved.

The information provided in the Data Access Technical Knowledge Base is provided "as is" without warranty of any kind. Data Access Corporation disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Data Access Corporation or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Data Access Corporation or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply.