GUI : change edit text to predefined number by selecting from dropdown menu

Hello, Im in need of help.
Im a Matlab beginner and I cant figure out how to change the content of edit text in GUI by selecting in dropdown menu.
In short I have some vehicle data that I need displayed in edit text, and I have lots of vehicles.
I need to create multiple edit texts, and update them when I change vehicle type in dropdown menu. They have to be edit text because you have to be able to change them when you open GUI.
Any help would be much appreciated.

 采纳的回答

Try this (untested)
% Get the number (1, 2, 3, ...) that was selected.
selectedItem = get(handles.popup1, 'Value');
% Get the entire list of all strings in the popup.
contents = get(handles.popup1, 'String');
% Extract just the one that was selected by the user.
selectedItemString = contents{selectedItem};
% Send this to the edit field.
set(handles.editText1, 'String', selectedItemString);
I think it should be well explained by the comments.

2 个评论

Thank you very much, not exactly what I needed, but by your example I figured out loads by trial and error
This works perfect, of course I am just putting in the string directly for the selectedItemString.
Thanks!

请先登录,再进行评论。

更多回答(1 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Simulink Environment Customization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by