Getting Cell location of checkboxes on selection (UITable)

5 ビュー (過去 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?
  2 件のコメント
Jason
Jason 2020 年 3 月 15 日
Yes that works, thanks
J. Alex Lee
J. Alex Lee 2020 年 3 月 15 日
cool, sure thing!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by