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: Thu, 13 Aug 2009 22:40:20 +0000 (UTC)
Organization: Naval Surface Warfare Center
Lines: 23
Message-ID: <h624oj$6ms$1@fred.mathworks.com>
References: <h61vft$b96$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 1250203220 6876 172.30.248.37 (13 Aug 2009 22:40:20 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 13 Aug 2009 22:40:20 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 513223
Xref: news.mathworks.com comp.soft-sys.matlab:563264


"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