Effacer les filtres
Effacer les filtres

Add new DropDown item in App designer 2019a

37 vues (au cours des 30 derniers jours)
CamPe
CamPe le 3 Mai 2020
Commenté : CamPe le 11 Mai 2020
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

Réponse acceptée

Tommy
Tommy le 3 Mai 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?
  1 commentaire
CamPe
CamPe le 11 Mai 2020
It worked prefect, thank you very much

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by