How can I write in multiple edittexts using a 'for' loop?
2 views (last 30 days)
Show older comments
Hey guys, I'm creating a GUI in GUIDE and I need to write in multiple edittexts, say...100 of them. Is there a manner to write in one at a time, in a for loop, for example?
My first idea was to execute this command:
set(handles.edittext01,'string',text(1:end));
inside the loop, incrementing the expression: 'edittext01' in each iteration, but I guess it's not possible, because errors appear.
I would be grateful if someone could help me. Thank's
1 Comment
Jan
on 11 Jul 2013
"Error appears" does not allow to suggest an improvement. Better post the code and a copy of the complete error message.
Accepted Answer
Jan
on 11 Jul 2013
If you have 100 edit fields, "edit01" is a bad naming scheme. Do you see any chance to store the handles in a vector:
figure; % dummy for demonstration
handles.editH = zeros(1, 100);
for k = 1:100
col = floor((k - 1) / 10);
row = mod(k, 10);
handles.edit(k) = uicontrol('Style', 'edit', ...
'Position', [10 + col * 40, row*30, 30, 20]);
end
This is a demo only and the result will not match the figure nicely.
More Answers (0)
See Also
Categories
Find more on Text Data Preparation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!