Getting Cell location of checkboxes on selection (UITable)

조회 수: 2 (최근 30일)
Jason
Jason 2020년 3월 13일
댓글: J. Alex Lee 2020년 3월 15일
Hello, I have a UITable that contains checkboxes (logical data type). I want o be able to select cells and create a list (in a listbox) of those selected cells (this will then be passed to a motorised stage to scan those positions on a sample).
I am able to highlight selected cells and add these to a list box when I select the cell, but not when the checkboxes are selected.
How do I get the location of each of the selected checkboxes?
This is my code.
% Cell selection callback: UITable
function UITableCellSelection(app, event)
indicies = event.Indices
col=indicies(1); row=indicies(2);
s1 = uistyle('BackgroundColor','red');
s2 = uistyle('BackgroundColor','green'); %Not using this yet!
addStyle(app.UITable,s1,'cell',[col row]); %New feature!
%Add to list box
selectedString = strcat('column=',num2str(row),' row=',num2str(col)); % Needs to be a string
listBoxData = app.ListBox.Items %Get current values
if isempty(listBoxData) || ~any(strcmpi(listBoxData, selectedString))
listBoxData = [listBoxData, selectedString];
app.ListBox.Items=listBoxData;
end
end

채택된 답변

J. Alex Lee
J. Alex Lee 2020년 3월 13일
Is it as simple as defining a CellEditCallback?

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by