Select all items of a list box within app designer
27 次查看(过去 30 天)
显示 更早的评论
Hello together,
I have a rather simple problem and I am wondering whether it´s my or Matlab´s fault.
In an app, created with App Designer, I have a list box with 1000+ entries. I want to create a button, that selects all items in the list box, when pushed.
I figured, the easiest way is to simply get all items in the list box and then pass it to the app.ListBox.Value variable (code below)
It definitely works, but it is really slow. Reading the items is not the problem:
Read items from the list box: 0.000263 s
Write items to the Value variable: 5.6392 s
If I click on the first item, scroll all the way down to the last, press Ctrl+Shift and click the last item, all items are selected instantly. So there must be a way to do this without waiting for 5 or more seconds...
Does anybody have a better solution or can tell me, what I am doing wrong?
Best regards,
Justus
% Button pushed function: SelectAllButton
function SelectAllButtonPushed(app, event)
% Start timer
tic
% read all items from the list box
Items = app.ListBox.Items;
% stop the timer and write the time to a variable
ReadItemsTime = toc;
% start a second timer
tic
% Select all Itmes, by passing the cell array to the Value
% variable
app.ListBox.Value = Items;
% stop the second timer
WriteValueTime = toc;
% display the times
disp(['Read items from the list box: ' num2str(ReadItemsTime) ' s'])
disp(['Write items to the Value variable: ' num2str(WriteValueTime) 's'])
end
3 个评论
Mohammad Sami
2020-3-23
This looks like an issue with how Matlab internally implemented the setting of values. I think it can be sped up. Perhaps you can raise a support ticket to highlight this performance issue.
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!