How to arrange input fields straight below each other using inputsdlg?

조회 수: 9 (최근 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:

채택된 답변

Bora Eryilmaz
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
  댓글 수: 1
Brezelbayer
Brezelbayer 2023년 1월 12일
Thanks! Well, I guess for a perfect alignment it's better to create an app with a GUI than using inputsdgl.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Display and Presentation에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by