필터 지우기
필터 지우기

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

조회 수: 14 (최근 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 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