How to sort string in a list of edit box based on a toggle buttons for each of them?

2 次查看(过去 30 天)
I am currently working on a creating a to-do list and I am stuck on sorting my values and strings of other uicontrols. I created a list of edit boxes with GUIDE and each of them has a toggle box for importance, checkbox and due date entry. When the user pushes it down it just identifies that the correlating edit box and etc are important. I want to be able to sort this information. Such as, if there are multiple toggle boxes pushed down, I want them to be moved to the top of the list. So basically, I need to swap the information between the top ones that are not toggled between the ones toggled.
I have attached a picture of what the guide looks like below:
  2 个评论
Stephen23
Stephen23 2017-4-9
编辑:Stephen23 2017-4-9
+1 for using a sensible date format!
Question for clarity: you have multiple sets of "Entry" + "Due Date" + button + check box, and you want to physically rearrange their order based on the button status?
This is certainly possible, but would not be a typical action.
Jacob Schoeb
Jacob Schoeb 2017-4-10
Yes, I want to switch around the values of the check boxes and toggle button, but also want to switch the scripts of the entries. When I sort them by which of them have been toggled to important, I want the important ones go on top! Also, The checkboxes are there in order to select multiple entries to delete them with a delete button which I have already figured out how to do.
Thanks for your inquiry.

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2017-4-9
Create four vectors of handles, one for Entries, one for Due Date, one for the toggle buttons, one for the check boxes.
get() the String properties of the Entries vector, and Due Date vector, and get() the Value properties of the toggle buttons vector, and check boxes vector. This will give you cell arrays.
Convert the Value cell array to matrix. sort() with 'stable' property, returning the indices as well as the values.
Index the other cell arrays at the indices returned by the sort(), getting out cell arrays that have been re-ordered according to the Important property.
set() the String properties of the Entries handles to the adjusted cell array, likewise for Due Date; likewise set() the Value properties of the other two vectors as appropriate.
  7 个评论
Jacob Schoeb
Jacob Schoeb 2017-4-10
I'm getting an error: 'Error using set Conversion to double from cell is not possible.'
Well initially the program makes only one line of boxes, buttons,etc visible. the others have visibility off. I have an add button that makes another line of those visible up to 10 entries. Then the checkboxes are for a delete button I have where you can select multiple entries to delete that consists of nested for loops and if statements. The ones deleted erase the values and strings and make it invisible. And the other ones are shifted up if the entry above is invisible.
and then I have a the sort popup menu with sorting by due date or importance. The sorting is the only part I have left to create.
And, sorry for ignoring your uitable suggestions, I understand that that would be easier but I would like to do the way I am doing it. Thank you!
Walter Roberson
Walter Roberson 2017-4-10
EntryEditsVString = get(EntryEditsV, {'string'});
DueDateEditsVString = get(DueDateEditsV, {'string'});
ImportantTogglesVValue = get(ImportantTogglesV, {'value'});
CheckboxesVValue = get(CheckboxesV, {'value'});
... now do the sorting, producing IndexC. Then
ReorderCheckboxes = CheckboxesVValue(IndexC);
ReorderEntryEdits = EntryEditsVString(IndexC);
ReorderDueDateEdits = DueDateEditsVString(IndexC);
ReorderImportantToggles = ImportantTogglesVValue(IndexC);
set( DueDateEditsV, {'String'}, ReorderDueDateEdits);
set( EntryEditsV, {'String'}, ReorderEntryEdits);
set( CheckboxesV, {'Value'}, ReorderCheckboxes);
set( ImportantTogglesV, {'Value'}, ReorderImportantToggles);

请先登录,再进行评论。

更多回答(0 个)

类别

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