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.

 Respuesta aceptada

Image Analyst
Image Analyst el 28 de Mayo de 2013
Editada: Image Analyst el 28 de Mayo de 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 comentarios

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!

Iniciar sesión para comentar.

Más respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 28 de Mayo de 2013
Editada: Azzi Abdelmalek el 28 de Mayo de 2013
It's better to use an uitable and make its cells editable

Categorías

Más información sobre Interactive Control and Callbacks en Centro de ayuda y File Exchange.

Preguntada:

el 28 de Mayo de 2013

Comentada:

el 15 de Jun. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by