Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: dialog program: make LISTBOX initially hidden or use repopulate?


From   Sergiy Radyakin <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: dialog program: make LISTBOX initially hidden or use repopulate?
Date   Wed, 11 Dec 2013 17:18:57 -0500

Jonah, see the example of James Hassell from 2006 here:

http://www.stata.com/statalist/archive/2006-11/msg00420.html

It implements the first method you describe.

Best, Sergiy Radyakin


On Wed, Dec 11, 2013 at 2:15 PM, Jonah Sol Gabry <[email protected]> wrote:
> Hi all,
>
> I'm trying to find the best solution to the following dialog
> programming problem:
>
> I have two list boxes and I would like the entries in LISTBOX 2 to
> change depending on which entry in LISTBOX 1 is selected. Two
> different possible methods occurred to me but I'm not quite sure how
> to accomplish either of them or if they are even possible. For
> simplicity, suppose LISTBOX 1 offers only two possible selections, a
> and b (although there will be many more in reality).
>
> Method 1: use onselchangelist() to specify how LISTBOX 2 should be
> repopulated depending on whether a or b is selected in LISTBOX 1. But
> I'm having trouble figuring out how to use the repopulate member
> function in this way.
>
> Method 2: get rid of LISTBOX 2 and instead have LISTBOX 2a and LISTBOX
> 2b. The idea would be that both of them would be hidden by default and
> then shown depending on whether entry a or entry b in LISTBOX 1 is
> selected. Below is some simplified code along the lines of what I
> imagine this would look like (except I don't know how to specify that
> LISTBOX lb_list2a and LISTBOX lb_list2b should be hidden by default).
>
> Thank you in advance for any advice. It's greatly appreciated!
>
>
> CODE:
>
> *here are the list boxes:
> LISTBOX lb_list1 . . . . ,  ///
>  contents(list1_contents) ///
>  onselchangelist(list2show)
>
> LISTBOX lb_list2a . . . . ,  ///
>  contents(list2a_contents)
>
> LISTBOX lb_list2b . . . . ,  ///
>  contents(list2b_contents)
>
> *here's a list containing the iactions corresponding to onselchange(list2show)
> LIST list2show
>  BEGIN
> main.lb_list2a.show
> main.lb_list2b.show
> END
>
> *here are the lists with the contents for the list boxes
> LIST list1_contents
> BEGIN
> a
> b
> END
>
> LIST list2a_contents
> BEGIN
> item1
>   item2
> item3
> item4
> END
>
> LIST list2b_contents
> BEGIN
> item1
>   item4
> END
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index