how to check all boxes in uitable column with a button?

16 ビュー (過去 30 日間)
Shalaka Kollerkandy
Shalaka Kollerkandy 2021 年 1 月 29 日
回答済み: dpb 2021 年 1 月 30 日
Hi, I want to create a button under my uitable that will check all the boxes in the uitable. currently all the check boxes are in one column so I basically want to select all the cells in this column when I click the button. My uitable data is from an excel file that is read in, if that changes anything.

回答 (1 件)

dpb
dpb 2021 年 1 月 30 日
Just put the code to set the column variable all to TRUE in the callback for your pushbutton...trivial example from uitable doc...
t = readtable('patients.xls');
vars = {'Age','Systolic','Diastolic','Smoker'};
t = t(1:5,vars);
hUIfig = uifigure;
uit = uitable(hUIfig,'Data',t);
uib=uibutton(hUIfig,'Text','Check All', ...
'ButtonPushedFcn', @(btn,event) fnButtonPushed(btn,uit));
has a table with one Smoker checked and a "Check All" button:
The button function would look something like:
function plotButtonPushed(btn,uit)
uit.Data.Smoker=true(height(uit.Data),1);
end
NB: This updates the data table in the GUI uitable but NOT that in the local copy of the table, t.

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by