Controlling a ListBox's items from a PopupMenu
3 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I have a popup menu that changes a global variable in its callback, and the global variable is used as an index for several things to keep track of where I'm at in my data structure.
I also have a Listbox. What I want to do is, whenever I select something from the popupmenu, the listbox should update its selections according to what the value picked in the popup menu (the global index) is.
Is there a way to force the list to update whenever the popup updates?
0 件のコメント
回答 (1 件)
Ben11
2014 年 7 月 14 日
Yes. In the popup menu callback you can edit what appears in the Listbox using its handles and "string" property. The simpler would be to pre-define elements you want to display depending on the selection in the popup menu and then assign them as the "string" property of the Listbox.
Simple example (popupmenu callback):
switch(get(hObject,'Value')) % get current value selected in popup menu. I'm assuming numbers but it can be strings or else.
case 1
set(handles.Listbox,'String',StringArray1);
case 2
set(handles.Listbox,'String',StringArray2);
etc.
end
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!