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

88 views (last 30 days)
ori on 21 Sep 2015
Answered: Walter Roberson on 21 Sep 2015
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 Comment
Jan on 21 Sep 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?

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 21 Sep 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);

Community Treasure Hunt

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

Start Hunting!