What is the best way of deleting multiple rows of a uitable using a pushbutton?
1 回表示 (過去 30 日間)
古いコメントを表示
I am creating a to-do list where entries, dates, identification of importance are each column in a uitable. I want to delete one or more rows depending on what the user selects or identifies with a delete button that is also in the GUI.
0 件のコメント
回答 (1 件)
Walter Roberson
2017 年 4 月 14 日
Use the same kind of vector of handles that we discussed in https://www.mathworks.com/matlabcentral/answers/334500-how-to-sort-string-in-a-list-of-edit-box-based-on-a-toggle-buttons-for-each-of-them#answer_262392
When you have converted the vector of checkbox values from cell to matrix, then you can logical() that to get a mask. The mask would correspond to entries to delete. For your purpose it is probably easier to use a vector of things to save:
mask = logical(MatrixCheckboxesValue);
IndexC = ~mask;
Then this next section is copied directly from that previous code:
ReorderCheckboxes = CheckboxesVValue(IndexC);
ReorderEntryEdits = EntryEditsVString(IndexC);
ReorderDueDateEdits = DueDateEditsVString(IndexC);
ReorderImportantToggles = ImportantTogglesVValue(IndexC);
but only a subset of the locations are to be changed:
num_kept = sum(IndexC);
set( DueDateEditsV(1:num_kept), {'String'}, ReorderDueDateEdits);
set( EntryEditsV(1:num_kept), {'String'}, ReorderEntryEdits);
set( CheckboxesV(1:num_kept), {'Value'}, ReorderCheckboxes);
set( ImportantTogglesV(1:num_kept), {'Value'}, ReorderImportantToggles);
After that, you have some unused entries to deal with, the ones from num_kept+1:end . You could delete them, or you could set their visible off and put them in a pool of already-created objects ready for re-use.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!