how to take input from created edit fields in app designer

42 visualizaciones (últimos 30 días)
I have created Edit Fields in the interface, but I have no idea how to store values from the created EditFields.
Example: when I enter n as 2 and press button, It creates 2 edit fields, code is as follows.
% Button pushed function: Button
function ButtonPushed(app, event)
for i = 1:n
app.EditFields=uieditfield(app.UIFigure,'text','Position',[100 350-20*i 150 20],'Placeholder',sprintf('Enter number '));
After entering the values in editfields and pushing the button2, The values must be store in a cell.

Respuesta aceptada

Image Analyst
Image Analyst el 19 de Jul. de 2022
Editada: Image Analyst el 19 de Jul. de 2022
I don't suggest you create them on the fly. I suggest you just create them all with known names in advance. Just set their visible property to hidden/off. Then (in the button callback if you wish) you can use a switch or if to make all visible up until the nth box and invisible after that. Then since you know their names, you can easily get the contents just like you did for n.
Attach your .mlapp file if you need more help, after you read this:
  1 comentario
Sri Vishnu Katreddi
Sri Vishnu Katreddi el 19 de Jul. de 2022
Thank you so much, I'm using a switch case to make the fields visible. Also will upload a .mlapp file next time when i need help.

Iniciar sesión para comentar.

Más respuestas (1)

Monica Roberts
Monica Roberts el 19 de Jul. de 2022
One problem is that you aren't storing the handles to the edit fields as separate entities. As you loop, "app.EditFields" is being overwritten, so you only have access to the latest one. But in general, to access the value, you can reference the value:
It looks like you may want to check out this answer:


Más información sobre Environment and Settings en Help Center y File Exchange.


Community Treasure Hunt

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

Start Hunting!

Translated by