Borrar filtros
Borrar filtros

How to locate the data in the middle of the column- uitable?

31 visualizaciones (últimos 30 días)
ori
ori el 21 de Sept. de 2015
Comentada: mehdi amini el 2 de Jun. de 2023
Im trying to make a table by using uitable. How can I put the data in the middle of the column instead of the matlab defult- in the right? thanks
  1 comentario
Jan
Jan el 21 de Sept. de 2015
What does "put" mean here? Do you mean the initial position of the cursor or do you define the "Data" property of the uitable?

Iniciar sesión para comentar.

Respuestas (2)

Jasmine Poppick
Jasmine Poppick el 17 de Mzo. de 2023
Starting in R2019b, you can specify table text alignment using addStyle. Create a style object with a specified HorizontalAlignment value using uistyle. You can then add the style to the whole table, or to specific rows, columns, or cells.
For example:
fig = uifigure;
t = uitable(fig,"Data",magic(3));
s = uistyle("HorizontalAlignment","center");
addStyle(t,s)

Walter Roberson
Walter Roberson el 21 de Sept. de 2015
and remember to set a monospaced font.
uitable supports HTML, but it is not easy to get it to center items. Supposing you have a cell array of strings STRINGS, then:
numpixels = 50;
cells_for_table = strcat(sprintf('<html><tr align=center><td width=%d>', numpixels), STRINGS(:));
set(handles.uitable1, 'Data', cells_for_table);

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by