Getting Cell location of checkboxes on selection (UITable)

4 views (last 30 days)
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

Accepted Answer

J. Alex Lee
J. Alex Lee on 13 Mar 2020
Is it as simple as defining a CellEditCallback?

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!