MATLAB: Select all the data in listbox using single click of pushbutton

single click to select all the data in listbox

I have a GUI with 3 pushbuttons(Load, Select All & Extract)and listboxDATA. I am able to import data in the listbox using load but how do I set callback for select_all to select all the data in the listboxDATA. I can select all the data individually in listbox but that could be more than 200 lines.

Best Answer

Hi Ghanshyam,
In your 'Select All' pushbutton callback, you can add the following code to select all elements currently displayed in your listbox:
sizeOfListBox = numel(get(handles.listbox1, 'String'));
set(handles.listbox1,'value',1:sizeOfListBox);
You can replace 'listbox1' with the Tag of your custom listbox.
Note: You will also need to adjust the 'Max' and 'Min' properties of the Listbox so that multiple item selection is allowed. 'Max' must be at least 2 more than 'Min'.