Clear Filters
Clear Filters

Add new DropDown item in App designer 2019a

37 views (last 30 days)
Im new in Matlab, and Im trying to add a new item to the existing dropdown items, from an EditField text value, but I havent find out how, this is what Im doing, but Im not sure how to finish it:
function EditFieldValueChanged(app, event)
new = app.EditField.Value;
hDropDown = app.DropDown;
currentItems = get(hDropDown);
[~, index] = ismember(hDropDown.Value, hDropDown.Items);
newItems = {currentItems,new};
newItems(index) = [];
end

Accepted Answer

Tommy
Tommy on 3 May 2020
This will add the edit text's string to the drop down's list of items as long as it is not already there:
function EditFieldValueChanged(app, ~)
new = app.EditField.Value;
if ~any(ismember(app.DropDown.Items, new))
app.DropDown.Items = [app.DropDown.Items new];
end
end
Is this what you're looking for?

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!