UITable in App Designer strips leading white space

조회 수: 5 (최근 30일)
Felix Widmaier
Felix Widmaier 2017년 2월 10일
댓글: Usaid 2022년 8월 4일
When using uitable in GUIDE, I was able to pad strings with leading spaces to get them right aligned like in the following (using a monospace font):
Currently I am considering switching to App Designer. I am using the same space-padded strings but here the uitable seems to strip them off. That is the result looks like the following:
Is there a way to make uitable in App Designer keep the spaces like it did in GUIDE? Or even better, is there a way to directly right-align the strings without the need of padding?

채택된 답변

Felix Widmaier
Felix Widmaier 2017년 3월 17일
I asked the same question on StackOverflow and got an answer there. See http://stackoverflow.com/questions/42224921/right-align-values-in-uitable-in-app-designer. Note that the answer there is about right-aligning (which is what I actually want), not about the trimmed spaces.

추가 답변 (1개)

Greg 2021년 10월 27일
I encourage the use of proper horizontal-alignment-right as described in Felix's answer. However, in the event somebody has a real need for leading spaces (and apparently also consecutive interior spacing), use the unicode character 160. It is a special character designed to be blank/invisible but not classified as whitespace.
Example code:
text = ["Seafood";char(160+zeros(1,5)) + "Nachos"];
t = uitable(uigridlayout(uifigure,[1,1]),'Data',text);
  댓글 수: 1
Usaid 2022년 8월 4일
I think the character you are refering to is a No-Break Space Unicode character.

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


Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by