Need to clear the GET in a DCCOMBOBOX

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
GeneB
Posts: 158
Joined: Sun Jan 31, 2010 8:32 am
Location: Albuquerque, New Mexico, USA
Contact:

Need to clear the GET in a DCCOMBOBOX

#1 Post by GeneB »

In the following code, if you enter any value in 'account', then click on the drop down and select a 'type', and then 'Save', all is well.
If you then go back up to enter another 'account', but skip the 'type' since it is still showing the last 'type' selected in the dropdown, no value is assigned to cType even though it is showing in the GET.

How can I either clear the DCCOMBOBOX get so that the user is forced to select a 'type', or have the value showing assigned to the variable cType?

Thanks,
GeneB

Code: Select all

#include  "dcdialog.ch"
FUNCTION Main()
local cAcct:=SPACE(4), cType:=SPACE(1) ;
    , aType:={"E expense","L liability","A asset"} ;
    , GetOptions, getlist:={}

@ 1,1 DCSAY "Acct" GET cAcct  PICTURE "!!!!" SAYSIZE 8  GETSIZE 7

@ 3,1 DCSAY "Type"
@ 3,10 DCCOMBOBOX cType LIST aType ;
         SIZE  12,4  TYPE XBPCOMBO_DROPDOWNLIST

@ 6,1 DCPUSHBUTTON  CAPTION "SAVE" SIZE 11,1.5 ;
           ACTION {|| DC_MsgBox(,,{"Acct " + cAcct + "   Type " + cType},,.t. ) ;
                           , cAcct := SPACE(4) ;
                           , cType := SPACE(1) ;
                           , DC_GetRefresh(getlist) }

DCREAD GUI FIT ADDBUTTONS
RETURN NIL

PROC AppSys() ; return
Last edited by GeneB on Tue Mar 05, 2013 8:21 am, edited 1 time in total.

Cliff Wiernik
Posts: 605
Joined: Thu Jan 28, 2010 9:11 pm
Location: Steven Point, Wisconsin USA
Contact:

Re: Need to clear the get in a DCCOMBOBOX

#2 Post by Cliff Wiernik »

In my experience with a DCCombobox, if you want to start with a default of blank or go to a blank, first you must have a blank as an option in your array of items. Otherwise, if you provide a default value that is not in the list, it will automatically select the closest match anyways without you knowing.

Then to change it, you likely need something like this: o:xbpsle:setdata()

I did not test this though.

User avatar
RDalzell
Posts: 205
Joined: Thu Jan 28, 2010 6:57 am
Location: Alsip, Illinois USA

Re: Need to clear the get in a DCCOMBOBOX

#3 Post by RDalzell »

Try:
aType := DC_AConvert(aType)[1] // After you define the array
cType := aType[1] rather than cType := Space(1)

User avatar
GeneB
Posts: 158
Joined: Sun Jan 31, 2010 8:32 am
Location: Albuquerque, New Mexico, USA
Contact:

Re: Need to clear the get in a DCCOMBOBOX

#4 Post by GeneB »

Your suggestions solved it.
I added a blank fourth array element, SPACE(1), to aType
After the "Save", instead of resetting cType:=SPACE(1), I used cType:=aType[4].
I get exactly what I needed.

Thanks to both for your help.
GeneB

Post Reply