From: jens on
Hi Matlab users

I have a GUI with a listbox and some checkbuttons. I used the checkbuttons to update the strings in the listbox. When I do not have marked the first string in the listbox and try to update the listbox I get the error:

Warning: single-selection listbox control requires that
Value be an integer within String range
Control will not be rendered until all of its parameter
values are valid

My code is something like:

r={'Test1' 'Test2' 'Test3''} %the contents of the cellarray r depends on what checkbuttons there are checked (value=1).

set(hlb,'string',r) %hlb is the handle to the listbox

Should I maybe reset the string in the listbox before I update it with new strings?

Best Regards

Jens
From: Walter Roberson on
jens wrote:
> When I do not have
> marked the first string in the listbox and try to update the listbox I
> get the error:
>
> Warning: single-selection listbox control requires that
> Value be an integer within String range
> Control will not be rendered until all of its parameter
> values are valid
> My code is something like:
>
> r={'Test1' 'Test2' 'Test3''} %the contents of the cellarray r depends on
> what checkbuttons there are checked (value=1).
>
> set(hlb,'string',r) %hlb is the handle to the listbox

You have an old Value for the handle that is outside the range
1:length(r). Easiest work around:

set(hlb, 'string', r, 'Value', 1);
From: Matt Fig on
You may need to explicitly set the 'value' property of the listbox to 1 every time before you change it's string. That usually takes care of this error.

set(hlib,'value',1,'string',r)