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.

 Accepted Answer

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 Comments

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!

Sign in to comment.

More Answers (1)

It's better to use an uitable and make its cells editable

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!