Loop through multiple EditField controls placed inside the App Designer and get values from them.
    10 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Paollo007
 el 9 de Jul. de 2020
  
    
    
    
    
    Comentada: Paollo007
 el 10 de Jul. de 2020
            Hi, I have placed multiple EditField controls within my App Designer aplication that I am trying to build.
I am now trying to create a function which will loop through all the 'EditField.Value' controls, compare the value and replace it if required.
How do I get hold of 'EditField.Value' programaticly by looping through all the controls at once?
I was hoping to use control name to access it directly but just cannot work out how it can be done.
Thank you for your help
0 comentarios
Respuesta aceptada
  Dennis
      
 el 10 de Jul. de 2020
        If your edit fields have systematic names you can do it like this:
for i=1:3
    app.(sprintf('EditField%d',i)).Value
end
You just need to pay attention, that you might need to rename the first EditField to EditField1. 
You can also create EditFields in a loop, which is really helpful, when you need to create more than 2 or 3. 
For example you could  put this in your startupFcn:
            for i=3:-1:1 
                editFields(i)=uieditfield(app.UIFigure,'numeric');
                editFields(i).Position = [90 100+i*40 100 22];
            end
            app.editFields=editFields; %you need to add the editFields property to your app for this to work
Then you can simply loop through your handles:
            for i=1:3
                app.editFields(i).Value;
            end
Más respuestas (0)
Ver también
Categorías
				Más información sobre Data Type Identification 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!