Change cell (uitable) properties individually and permanently after click

9 ビュー (過去 30 日間)
Constantin Vlad Mihai
Constantin Vlad Mihai 2022 年 5 月 18 日
回答済み: Rahul 2025 年 4 月 14 日
As the summary says; when I want to click an individual cell in an uitable, i want it to change properties. For example, when I click a certain cell, I want the cell to change its foreground color permanently. I hope it's not too hard to do. Thank you in advance.

回答 (1 件)

Rahul
Rahul 2025 年 4 月 14 日
I understand that you wish to change the 'ForegroundColor' of the particular cell of the 'uitable' when the cell is clicked by the user. As I understand the 'ForegroundColor' of the 'uitable' changes the color of the text present inside the cells of the 'uitable'.
This can be done in the following ways:
  • Add a 'CellSelection' callback to the 'uitable' component.
  • Inside the 'CellSelection', create a 'uistyle' object with the required styling.
  • Use the 'addstyle' function to add the 'uistyle' created to the particular cell.
Here is an example:
function UITableCellSelection(app, event)
if ~isempty(event.Indices)
row = event.Indices(1);
col = event.Indices(2);
% Create a style object
style = uistyle('FontColor', 'red');
% Add the style to the selected cell
addStyle(app.UITable, style, 'cell', [row, col]);
end
end
The following MATLAB Answer can be referred:
The following MathWorks documentations can be referred to know more:
Thanks.

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by