Borrar filtros
Borrar filtros

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

5 visualizaciones (últimos 30 días)
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:

Respuesta aceptada

Bora Eryilmaz
Bora Eryilmaz el 12 de En. de 2023
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 comentario
Brezelbayer
Brezelbayer el 12 de En. de 2023
Thanks! Well, I guess for a perfect alignment it's better to create an app with a GUI than using inputsdgl.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by