How to delete items entries in a listbox in appdesigner
    1 回表示 (過去 30 日間)
  
       古いコメントを表示
    
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
0 件のコメント
回答 (1 件)
  Deepak
 2025 年 1 月 17 日
        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.
0 件のコメント
参考
カテゴリ
				Help Center および File Exchange で Develop Apps Using App Designer についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!