Select/set ItemData index of drop down in App Designer
15 次查看(过去 30 天)
显示 更早的评论
Hi folks,
I created an app in app designer which has an Edit Field where a user can enter an IP and a drop down menu where you can choose the last five entered IPs. By pressing a button 'OK' the value entered in the Edit Field is compared with a document in which i store the last five entered IPs if it already exists, the index get's changed an it is set to the first position of the document to keep it chronological. The value is also passed to the next GUI where some actions happen. I have also a button from the second GUI to get back to the first GUI (in case you want to change the IP).
My problem right now is that when I choose an IP out of the list let's say IP #3 the index is also set to 3. If I try to enter a new IP by pressing the button in GUI 2 I get an 'out of index' error while GUI 1 goes through my saved list but not starting with index 1 but with index 3. Is there a way to set the index on the first Item and not the last I choose?
app.previouslyusedPortsDropDown.ItemsData = [1,2,3,4,5];
load('ports.mat','ports')
for i=1:1:5
app.previouslyusedPortsDropDown.Items(i) = cellstr(ports(i));
end
By leaving GUI 1 and entering GUI 2 I tried to clear all and delete GUI 1 to ensure everything get's loaded correctly as if I start the program out of nowhere.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!