How do I insert strings into UITable cells and format them in app designer?
18 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I'm writing my first app in app designer, though that may be independent of the UITable question I have. I inserted a table using the designer that looks like this:
When the "Calculate Imaging" button is pressed, the items in the table ("Wavelength, Focus, Object to Lens," etc. are calculated from the user input on the left for each row. Here is an example of how I input the data to the table:
app.UITable.Data{1,1} = num2str(lambda1, 4);
app.UITable.Data{1,2} = num2str(focus1, 4);
However, I don't like the display at all and can't seem to format it no matter how much I searh the web. I really don't understand why this isn't easier, it should be painfully easy. Here are the things I'd like to do:
- Center the numbers in the column (something like app.UITable.Data.HorizontalAlignment = 'center' ?????)
- Increase the row height to separate the numbers more
- After increase in height, center the numbers in the row
- Change the color and font type of the column headers (whose default is incredibly hard to see)
Thanks ahead of time for the help!
Cheers,
Dan
0 Kommentare
Antworten (2)
Sahithi Kanumarlapudi
am 4 Jun. 2020
Hi,
1.) You could use the 'uistyle' property to align the data in the rows to center. The following link has an example on how to do the same
2.) Regarding row height, there is no direct way to do that yet. You can change the FontSize property to change the row height. I have brought this issue to the concerned people and it might be considered in any future release.
3.) Regarding formatting the column headers, this is a known issue and the concerned parties may be investigating further.
Sahithi Kanumarlapudi
am 9 Jun. 2020
Hi,
'uistyle' was introduced in R2019b.
If you use R2019a or previous releases, refer to the following information.
As an alternative to the display position of the data, consider converting the numerical value to a character string and changing it to right alignment, or adjusting the display position using space.
fig = figure;
uit = uitable(fig);
uit.Data = rand(5,3);
data = num2cell(uit.Data); % convert to cell array
data2 = cellfun(@num2str,data,'UniformOutput',false); % convert to characters
uit.Data = data2; % Left alignement
% Insert spaces
data2 = cellfun(@(s)sprintf('%*s',12,s),data2,'UniformOutput',false);
uit.Data = data2; % like center alignment
Hope this helps!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!