How to delete items entries in a listbox in appdesigner

3 visualizaciones (últimos 30 días)
Paramonte
Paramonte el 15 de Oct. de 2019
Respondida: Deepak el 17 de En. de 2025
We have a listbox with multiple entries, and would want to be able to remove selected entries, for which we though we could use the mouse rifght button, as we had this functionalty already implemented when we used guide to build this UI. It was working well, but we are now updating the UI for appdesigner (seems not to work in appdesigner this right click mouse action)
We may consider other possible ways to be able to remove selected listbox entries besides the right mouse click action.
Thanks in advance

Respuestas (1)

Deepak
Deepak el 17 de En. de 2025
We can achieve the removal of selected listbox entries in App Designer by adding a button labeled "Remove Selected" and implementing a callback function for this button. The callback retrieves the indices of the selected items, removes these items from the "Items" property of listbox, and updates the listbox to reflect the changes. This approach provides a straightforward and user-friendly way to manage listbox entries without relying on right-click context menus, which may not be directly supported in App Designer.
Below is the sample App Designer code for the same:
% Button callback function
function removeSelectedButtonPushed(app, event)
% Get selected indices
selectedIdx = app.ListBox.Value;
% Get current listbox items
items = app.ListBox.Items;
% Remove selected items
items(selectedIdx) = [];
% Update listbox items
app.ListBox.Items = items;
% Clear selection
app.ListBox.Value = [];
end
Please find attached the documentation of functions used for reference:
I hope this helps in resolving the issue.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by