Get a Jumpstart with our Sample Apps
Results 1 to 14 of 14

Thread: Set Default Values in an Xdialog Multi Select Checkbox List

  1. #1
    Member
    Real Name
    John Tary
    Join Date
    Jan 2007
    Posts
    418

    Default Set Default Values in an Xdialog Multi Select Checkbox List

    I do not think this is possible, but I have two situations I am trying to accomplish. One is to set some checkboxes of an multi select checkbox list in an xdialog to be checked as default values and then for another list to start with them all checked. I cannot even get one to show a check at this point. Is the default mode not available with this type of dialog?

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,698

    Default Re: Set Default Values in an Xdialog Multi Select Checkbox List

    Prepopulate the dialog return variable.

    Try this

    Code:
    cities = <<%dlg%
    Atlanta
    New York
    Los Angeles
    Boston
    Johannesburg
    Sydney
    %dlg%
    ui_dlg_box("Multi-Select List Box",<<%dlg%
    {wrap=30}
    [%M%.30,5cities_chosen^#cities];
    {line=1,0};
    This variable shows what entries in the above list box are selected.;
    [%mw%.30,5cities_chosen];
    <OK>
    %dlg%)
    Then this

    Code:
    cities_chosen = <<%dlg1%
    Sydney
    Los Angeles
    %dlg1%
    cities = <<%dlg%
    Atlanta
    New York
    Los Angeles
    Boston
    Johannesburg
    Sydney
    %dlg%
    ui_dlg_box("Multi-Select List Box",<<%dlg%
    {wrap=30}
    [%M%.30,5cities_chosen^#cities];
    {line=1,0};
    This variable shows what entries in the above list box are selected.;
    [%mw%.30,5cities_chosen];
    <OK>
    %dlg%)
    Sorry, you specified check box. Working on another example.
    Last edited by Stan Mathews; 12-16-2011 at 02:09 PM.

  3. #3
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,698

    Default Re: Set Default Values in an Xdialog Multi Select Checkbox List

    Checkbox example.

    Code:
    color2_selected = "Orange,Cyan"
    color2_selected = stritran(color2_selected,",",crlf())
    
    colors = "Red,Green,Yellow,Blue,Purple,Orange,Lime,Cyan"
    colors = stritran(colors,",",crlf())
    dim a_colors[20] as C
    a_colors.initialize(colors)
    dim a_selected[20] as C
    a_selected[1] = "Orange"
    a_selected[2] = "Cyan"
    ui_dlg_box("Check Box-List Box",<<%dlg%
    {frame=1,1}
    {region}
    This control uses the '^$$' directive.;
    [.25,10color2_selected^$$colors!select_color];
    {lf};
    Value of check box-list box variable:;
    [.25,10colorname^#a_selected];
    {endregion}
    %dlg%,<<%code%
    if a_dlg_button = "select_color" then
    a_dlg_button = ""
    a_selected.clear()
    a_selected.initialize(color2_selected)
    end if
    %code%)

  4. #4
    Member
    Real Name
    John Tary
    Join Date
    Jan 2007
    Posts
    418

    Default Re: Set Default Values in an Xdialog Multi Select Checkbox List

    Stan, Thank you for this. I have only done xdialogs with action script. This will force me to finally learn to create this for myself. 2 Questions, is there a good tutorial/refrence on xdialog boxes, and how would you put one window next to another window in the dialog instead of them stacked ontop of each other? Thanks so much.

  5. #5
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,698

    Default Re: Set Default Values in an Xdialog Multi Select Checkbox List

    There's quite an extensive learning xdialog tutorial.

    I find it best to create the xdialog with the action script genie and then capture the xbasic for the action script. Then tweak the xbasic.

    Code:
    color2_selected = "Orange,Cyan"
    color2_selected = stritran(color2_selected,",",crlf())
    
    colors = "Red,Green,Yellow,Blue,Purple,Orange,Lime,Cyan"
    colors = stritran(colors,",",crlf())
    dim a_colors[20] as C
    a_colors.initialize(colors)
    dim a_selected[20] as C
    a_selected[1] = "Orange"
    a_selected[2] = "Cyan"
    ui_dlg_box("Check Box-List Box",<<%dlg%
    {frame=1,1}
    {region1}
    {row1}
    {col1}{frame=1,1}{region2}This control uses the '^$$' directive.
    [.25,10color2_selected^$$colors!select_color]{endregion2}
    {endcol1}
    {col2}{frame=1,1}{region1}Value of check box-list box variable:
    [.25,10colorname^#a_selected]{endregion1}
    {endcol2}
    %dlg%,<<%code%
    if a_dlg_button = "select_color" then
    a_dlg_button = ""
    a_selected.clear()
    a_selected.initialize(color2_selected)
    end if
    %code%)

  6. #6
    Member
    Real Name
    John Tary
    Join Date
    Jan 2007
    Posts
    418

    Default Re: Set Default Values in an Xdialog Multi Select Checkbox List

    Perfect. I need to dig into the tutorial. I see the col reference which I did not before. Thanks again.

  7. #7
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,211

    Default Bump to Stan

    Stan,
    If this checkbox list were populated from a table and another field was to be returned - how would you display one field and return the other?

    Say the Table data is this

    01 Red
    02 Green
    03 Yellow

    If the user checks Red from the first list how would you show 01 was the selection in the other box?
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  8. #8
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,698

    Default Re: Set Default Values in an Xdialog Multi Select Checkbox List

    I'd have to see the xdialog of what you are doing but in general, there are xdialog events to use. When the user makes a choice it sets or alters the value of a variable. You would need to capture that change and apply it appropriately to the other variable represented by the other box.

  9. #9
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,211

    Default Re: Set Default Values in an Xdialog Multi Select Checkbox List

    I found an example Selwyn did in the What's New in v10 section of the XD tutorial using {DATA=} with *FOR_EACH() on the elements initialized in a pointer array to create a CRLF List that is then used to populate the ListView control. I have been wondering how that could be done...and wouldn't you know there actually was an example!
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  10. #10
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    4,110

    Default Re: Set Default Values in an Xdialog Multi Select Checkbox List

    Robin,
    I have been collecting multiple fields from table records using delineations within table.external_record_content() and then from the dialog box selections, going through string variable searching, parsing, and list building using loops, filter_string_smatch() and word(). The attached example is an example that emulates your question with a table having the fields color_id and color and a dialog that presents check boxes for the user to chose, but returns a list of the color ids from the colors selected. You could always do this with lookup() but this way, it is one opening of the table, collecting the list you need, and filter_string_smatch() replaces the lookup() and many table openings. It's pretty fast a long as your list isn't huge. Hope this helps.
    Attached Files Attached Files
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  11. #11
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,211

    Default Re: Set Default Values in an Xdialog Multi Select Checkbox List

    Mike,
    1st question: if vLpicks_N is used to populate vxy, why doesn't msgbox(vxy) show any values but msgbox(vLpick_N) does?

    2nd question on this part:
    vLNM=table.external_record_content_get("colors","cid+'^^'+alltrim(color)","color","")
    for i=1 to w_count(vLNM,crlf())
    vLpicks_show=vLpicks_show+word(word(vLNM,i,crlf()),2,"^^")+crlf()
    next

    Did you add the '^^' just so you would have a unique pattern to find? very clever...
    So this is the part where you get both values but only display one?

    3rd question on the last string manipulation:
    vLpicks_N=""
    for k=1 to line_count(vLpicks_M)
    insearch="*"+alltrim(word(vLpicks_M,k,crlf()))
    vLpicks_N=vLpicks_N+word(filter_string_smatch(vLNM,insearch,crlf()),1,"^^")+crlf()
    next

    I understand that when a checkbox is selected a value is returned and when it is cleared so is the value. But what is the '*' for? Which takes me back to my 1st question - why can't the value of vxy be captured?

    I can see this will help my limited skills at string manipulation finally improve!
    Thanks for the example.
    Last edited by MoGrace; 01-24-2012 at 01:41 PM.
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  12. #12
    "Certified" Alphaholic Mike Wilson's Avatar
    Real Name
    mike wilson
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    4,110

    Default Re: Set Default Values in an Xdialog Multi Select Checkbox List

    Robin,
    1st question: if vLpicks_N is used to populate vxy, why doesn't msgbox(vxy) show any values but msgbox(vLpick_N) does?
    >> The vxy^#vLpicks_N is a presentation list box only and with the %r% makes it read only. So the vxy is mearly a place holder. If the %r% was removed, selection of that listbox would populate the vxy variable (I think it wasn't even dimmed). The presentation listbox can be converted to just text presentation by replacing [%r%.25,20vxy^#vLpicks_N] with {text=30,25vLpicks_N};

    2nd question on this part:
    Code:
    vLNM=table.external_record_content_get("colors","cid+'^^'+alltrim(color)","color","")
    for i=1 to w_count(vLNM,crlf())
    vLpicks_show=vLpicks_show+word(word(vLNM,i,crlf()),2,"^^")+crlf()
    next
    Did you add the '^^' just so you would have a unique pattern to find? very clever...So this is the part where you get both values but only display one?
    >> The double carrots is the delineator for each field value within the record string. Filter_string_smatch() can accept find strings with wildcards which will extract the record line from the vLNM crlf() list based on the checkboxes selected. Then from that, the ^^ delineates the field values in that line so word() can be used to extract the field value that you wish.

    3rd question on the last string manipulation:
    Code:
    vLpicks_N=""
    for k=1 to line_count(vLpicks_M)
    insearch="*"+alltrim(word(vLpicks_M,k,crlf()))
    vLpicks_N=vLpicks_N+word(filter_string_smatch(vLNM,insearch,crlf()),1,"^^")+crlf()
    next
    I understand that when a checkbox is selected a value is returned and when it is cleared so is the value. But what is the '*' for? Which takes me back to my 1st question - why can't the value of vxy be captured?
    >> You are correct that when a checkbox is selected a value is returned, but it is a multiselct checkbox, so the return is a growing (or shrinking) crlf() list. The loop captures each selections, the "*" is added a wildcard value because in the vLNM (List of Number and naMe), the record looks like:
    010^^aqua
    007^^black
    003^^blue
    009^^brown
    012^^burgundy
    etc

    If you selected blue, to extract out the color id for blue, you first get the line that contains blue. The * provides the wildcard to do that. Then the ^^ provides the delineator to extract the color id from that wildcard extracted line.

    Hope that helps.
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

  13. #13
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,211

    Default Re: Set Default Values in an Xdialog Multi Select Checkbox List

    Very clear explanation - Thank you Mike!

    ps: don't eat too many of those double 'carets' ;)
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  14. #14
    Member
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    996

    Default Re: Set Default Values in an Xdialog Multi Select Checkbox List

    Mike,

    Another Master piece xdailog example

    Thank you Mike

Similar Threads

  1. Select all items in multi-select list box by default
    By Jay Talbott in forum Alpha Five Version 8
    Replies: 10
    Last Post: 02-02-2012, 07:27 PM
  2. Multi-select list on form via embedded xdialog
    By Bill Murray in forum Alpha Five Version 10 - Desktop Applications
    Replies: 11
    Last Post: 02-23-2010, 06:38 PM
  3. checkbox list box and multi-select listbox on a form
    By gmeredith17 in forum Alpha Five Version 8
    Replies: 11
    Last Post: 09-05-2008, 12:21 PM
  4. How to set default values for checkbox control.
    By Fulltimer in forum Application Server Version 8
    Replies: 5
    Last Post: 02-07-2008, 10:48 AM
  5. Default checkbox values...
    By ppittman in forum Alpha Five Version 8
    Replies: 2
    Last Post: 04-18-2007, 01:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •