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

2 views (last 30 days)
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

Image Analyst
Image Analyst on 28 May 2013
Edited: Image Analyst on 28 May 2013
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
Zaky
Zaky on 28 May 2013
Thank you very much, not exactly what I needed, but by your example I figured out loads by trial and error
Farley Postgate
Farley Postgate on 15 Jun 2018
This works perfect, of course I am just putting in the string directly for the selectedItemString.
Thanks!

Sign in to comment.

More Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 28 May 2013
Edited: Azzi Abdelmalek on 28 May 2013
It's better to use an uitable and make its cells editable

Categories

Find more on Migrate GUIDE Apps 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!