Getting Cell location of checkboxes on selection (UITable)

2 vues (au cours des 30 derniers jours)
Jason
Jason le 13 Mar 2020
Commenté : J. Alex Lee le 15 Mar 2020
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

Réponse acceptée

J. Alex Lee
J. Alex Lee le 13 Mar 2020
Is it as simple as defining a CellEditCallback?
  2 commentaires
Jason
Jason le 15 Mar 2020
Yes that works, thanks
J. Alex Lee
J. Alex Lee le 15 Mar 2020
cool, sure thing!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by