add new string to listbox

  • Follow


Hi

How can I add new strings into a listbox? 

By using \n doesn't seem to do the job.
I tried:

initial_name=get(handles.listbox,'String')
new_name = sprintf('%s\n%s',initial_name,new_line) % assume there is a string store in variable new_line
set(handles.listbox,'String',new_name) gives the new_line and initial_line on the same line.

Thanks
Zheng
0
Reply zheng 3/26/2011 1:21:04 AM

On 25/03/11 8:21 PM, zheng chew wrote:

> How can I add new strings into a listbox?
> By using \n doesn't seem to do the job.
> I tried:
>
> initial_name=get(handles.listbox,'String')
> new_name = sprintf('%s\n%s',initial_name,new_line) % assume there is a
> string store in variable new_line
> set(handles.listbox,'String',new_name) gives the new_line and
> initial_line on the same line.

initial_name=cellstr(get(handles.listbox,'String'));
new_name = [initial_name;{new_line}];
set(handles.listbox,'String',new_name)
-1
Reply Think 3/26/2011 3:58:11 AM


"Think blue, count two." <roberson@hushmail.com> wrote in message <nvdjp.1160$4S1.799@newsfe21.iad>...
> On 25/03/11 8:21 PM, zheng chew wrote:
> 
> > How can I add new strings into a listbox?
> > By using \n doesn't seem to do the job.
> > I tried:
> >
> > initial_name=get(handles.listbox,'String')
> > new_name = sprintf('%s\n%s',initial_name,new_line) % assume there is a
> > string store in variable new_line
> > set(handles.listbox,'String',new_name) gives the new_line and
> > initial_line on the same line.
> 
> initial_name=cellstr(get(handles.listbox,'String'));
> new_name = [initial_name;{new_line}];
> set(handles.listbox,'String',new_name)

Hi,

Just create a cell and set by handles.

for i=1:length(list)
handles.names(i)=list(i) % fill handles struct with values that you want like to input in
end
set(handles.Listbox1,'String',handles.names)
-1
Reply punktrading 11/17/2011 9:20:29 PM

2 Replies
2095 Views

(page loaded in 0.174 seconds)

Similiar Articles:













7/20/2012 7:55:41 AM


Reply: