Schultz’s PowerBuilder Notes

Making DW Radio Buttons and Check Boxes look disabled


An effective GUI quickly communicates to the users  how they can interact with the current window.  For most datawindow edit styles, PowerBuilder supplies its developers with the means to visually show if  it is available to accept user input.  Unfortunately, if you are working with an older version of PB,  how to show  a disabled check box or a radio button is a  puzzle.  Here is how I deal with this issue.

Below is a datawindow from  one of my company’s applications written in PB 7.0 .  The Edit and dddw edit styles indicate its protected  status with its background color: white for enabled,  buttonface for disabled.  The radio button and checkbox edit styles do not have this option.  In order to find out if the column is  enabled or not, the user must actually click on it and see if changes.

The radio button and check boxes all appear to be enabled

The radio button and check boxes all appear to be enabled

My solution is to use the 3D look for enabled radio buttons and check boxes.   When a radio button or check box is disabled, I switch the object to 2D.  So the datawindow  changes to look like this:

Disabled items now appear in 2D

Disabled items now appear in 2D

This does the job of  clearly communicating to the user that the radio button “Weight Verify Physical Pallet” and the check boxes  “Taxable” and “Newspaper”  are disabled, while the other two check boxes are available to be selected and changed.

To achieve this 2D disable look in script, you can use modify script similar to the following:

ls_mod = “newspaper.Edit.Style.CheckBox.3D=No”
dw_1.Modify(ls_mod)

ls_mod = “wgt_vrfy.Edit.Style.RadioButtons.3D=No”
dw_1.Modify(ls_mod)

Another way to achieve this result is to borrow the technique discribed in the post The Ol’ Hidden Items in the dddw Part II.  This method also deals with tabular datawindow styles where multiple rows are displayed and the radio buttons and check boxes may be enabled in some rows, and disabled in others.

In this method, for each radio button or check box edit style, the datawindow has two copies of each of these columns.  One copy would not be protected and have the enabled 3d look, the other would be protected with the disabled 2D look.  The disabled copy would sit directly under the enabled copy.  Use a datawindow expression to determine the protect property and reuse this expression for the visibility property.  When the column is enabled, the visibility property of the enabled column would be turned on, and the visibility property of the disabled would be turned off.   When the column should be disabled, the visibility properties of the two copies would be reversed.  Voila!

Another option is to upgrade to 11.5 which fixes this issue.

On a side note, pressing the space bar is the  keyboard shortcut to toggle a check box with focus.

About these ads

March 17, 2009 - Posted by | 2. Datawindows, Datawindow PowerScript, Expressions, Modify and Describe | , , , , , , , , , , ,

9 Comments »

  1. Could you please give me the solution of how all radio buttons can be kept unchecked in PowerBuilder 11.5? Please give me sample code.

    Thanks in advance for your help.

    Kind Regards
    Alfaz

    Comment by Alfaz | April 12, 2010 | Reply

    • One way is to set the data to null value

      Comment by jinyc | October 4, 2011 | Reply

  2. Hello. But what about a datawindow showing some records which one field is a raddio button with only one value to choose? For example a survey with multi-optional questions: a question could have 4, 5, or more options to choose ( every option text is a record in a database table), and once an option is selected, the others options in the same question should be deselected automatically. How to include a raddiobutton style but only with one display value: Y? Thanks in advance.

    Comment by DaMaze | August 31, 2010 | Reply

    • set edit style for all those data items to radiobuttons and put them in one group

      Comment by jinyc | October 4, 2011 | Reply

  3. In PB12 the 2D look is no longer available, any thoughts on how we can achieve the same thing in PB12 ?

    Comment by GT | May 5, 2011 | Reply

    • to get 2d look for radibuttons in PB12, use dw.modify(“control.RadioButtons.3d=No”)

      Comment by jinyc | October 4, 2011 | Reply

  4. to get 2d look for radibuttons in PB12, set dw.object.control.RadioButtons.3d=”No”

    Comment by jinyc | October 4, 2011 | Reply

  5. dw.object.control.RadioButtons.THREED=”No”

    Also set Scale to Yes.

    Comment by powerobject | June 19, 2013 | Reply

  6. DataWindow is one of the most inconsistent objects in PowerBuilder. Disappointingly, there are no dynamic expressions for these attributes (Edit attributes and many others including DisplayOnly) even though implementing dynamic expressions for almost each attribute by Sybase should be a piece of cake. What is the point of having dynamic expressions for Color attributes when we cannot set a column’s DisplayOnly with a dynamic expression as well? We end up with a HYBRID code – dynamic expression for color and hand-coded logic for DisplayOnly. Really? Other inconsistencies – Protect instead of Enabled, ReadOnly (with dynamic expression), etc are not exposed in Properties, DW.Color and DW.Gradient.Color do not have dynamic expressions while object.Color and object.Gradient.Color do. DW Buttons are a joke – they act like text objects with a 3D border – insonsistent focus rectangle, no space-bar support, etc. Seriously?

    Comment by powerobject | June 19, 2013 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: