フィルターのクリア

What is the best way of deleting multiple rows of a uitable using a pushbutton?

1 回表示 (過去 30 日間)
Jacob Schoeb
Jacob Schoeb 2017 年 4 月 14 日
回答済み: Walter Roberson 2017 年 4 月 14 日
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.

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 4 月 14 日
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.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by