Controlling a ListBox's items from a PopupMenu
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Ben11
am 14 Jul. 2014
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 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!