Control ONE Pop Up Menu depending on ANOTHER Pop Up Menu

1 回表示 (過去 30 日間)
Miss B
Miss B 2020 年 4 月 4 日
編集済み: Geoff Hayes 2020 年 4 月 5 日
Hi everyone!
Hope all is well.
I have two pop-up menus named Popup 11 and Popup 16 with different selections on each pop-up menus. I tried the following code where If i select 1 in Popup 11, it should automatically select another in Popup16.
However, I got the following error:
'Unrecognized method, property, or field 'value' for class 'matlab.ui.control.UIControl'.
The following is my code:
function popup11_Callback(hObject, eventdata, handles)
if isequal(hObject.value, 1)
handles.popup16.value = 1;
end

回答 (1 件)

Geoff Hayes
Geoff Hayes 2020 年 4 月 4 日
Miss B - which version of MATLAB are you using? On older versions, you may need to do something like
if get(hObject, 'Value') == 1
set(handles.popup16, 'Value', 1);
end
Else put a breakpoint at the first line of this function, launch your GUI and select an item in your popup11. When the debugger pauses at this line, check to see what the fields are for hObject. Does a value field exist?
  9 件のコメント
Walter Roberson
Walter Roberson 2020 年 4 月 4 日
handles.popup16.Value = 30;
That is a request for entry #30 in popup16 to become the active entry.
What if there are fewer than 30 entries in popup16 at the time you make the request?
Setting the Value of a popup does not change the text displayed by a popup: it changes which of the text items are to be displayed.
If you wanted to change the text of the current selection to '-30-' then:
curpos = handles.popup16.Value;
handles.popup16.String{curpos} = '-30-';
Miss B
Miss B 2020 年 4 月 5 日
You are a life saver!!!!
Thank you so so so much!
I appreciate it so much!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by