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.

回答(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 CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by