How to arrange input fields straight below each other using inputsdlg?
4 次查看(过去 30 天)
显示 更早的评论
I'm using the Matlab Add-On "inputsdlg: Enhanced Dialog Box" to catch information of participants. The dialog box works fine but looks messy, because the input fields are not arraged straight below each other since the promptheadlines have different lenghts.
So, what can I do that all the input fields start at the same width position of my dialog box window?
Using the regular "inputdlg" is not an option because I have a dropdown field in the dialog box.
Code:
% Add-On "inputsdlg" must be installed, otherwise code wont run!
name = 'Participantdata'; % Titel
prompt = {'ParticipantID';'FirstName';'LastName';'Age';'Sex'}; % Collected Data
formats = struct('type', {}, 'style', {}, 'items', {}, 'format', {}, 'limits', {}, 'size', {});
formats(1,1).type = 'edit';
formats(1,1).format = 'integer';
formats(1,1).limits = [0 1000];
formats(1,1).size = [200 20];
formats(2,1).type = 'edit';
formats(2,1).style = 'edit';
formats(2,1).format = 'text';
formats(2,1).size = [200 20];
formats(3,1).type = 'edit';
formats(3,1).style = 'edit';
formats(3,1).format = 'text';
formats(3,1).size = [200 20];
formats(4,1).type = 'edit';
formats(4,1).format = 'integer';
formats(4,1).limits = [1 150];
formats(4,1).size = [200 20];
formats(5,1).type = 'list';
formats(5,1).style = 'popupmenu';
formats(5,1).items = {'m','f'};
formats(5,1).size = [200 20];
defaultanswers = {0, 'NaN', 'Nan', 1, 1};
[answer, canceled] = inputsdlg(prompt, name, formats, defaultanswers);
Output:
0 个评论
采纳的回答
Bora Eryilmaz
2023-1-12
You won't get perfect alignment, but you can pad the prompt strings with empty spaces:
prompt = {...
'ParticipantID'; ...
'FirstName '; ...
'LastName '; ...
'Age '; ...
'Sex '}; % Collected Data
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!