Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How do I code for placing an unknown number of Checkboxes?
Date: Fri, 14 Aug 2009 17:17:07 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 26
Message-ID: <h6466j$j2g$1@fred.mathworks.com>
References: <h61vft$b96$1@fred.mathworks.com> <h624oj$6ms$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1250270227 19536 172.30.248.37 (14 Aug 2009 17:17:07 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 14 Aug 2009 17:17:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1560446
Xref: news.mathworks.com comp.soft-sys.matlab:563475


"Shaun" <s@s.com> wrote in message <h624oj$6ms$1@fred.mathworks.com>...
> "Conrad Andrew" <conrad7@gmx.net> wrote in message <h61vft$b96$1@fred.mathworks.com>...
> > Hi there
> > 
> > I'd like to have a simple GUI where a number of checkboxes are placed programmatically. This number depends on user input so may vary. Let's say that on day 1, M may contain ['A1','A2'] but on day 2, it may have ['A1','A2','A3']. How do I generate a code that will place a number of checkboxes dependent on the size of M? 
> > 
> > Thanks very much for any help on this matter
> 
> 
> numChk = inputdlg('Number of Check Boxes');
> numChk = str2double(numChk);
> uh = zeros(1,numChk);
> for i = 1:numChk
>    uh(i) = uicontrol('Style','check'); 
>    if i > 1
>       pos = get(uh(i-1),'Position');
>       pos(2) = pos(2)+20;
>       set(uh(i),'Position',pos)
>    end
> end
> 
> 
> hth
> Shaun

This is good stuff Shaun. Exactly what I needed. Thanks a lot!