MATLAB Answers

how to select a variable in listbox then click on the delete button and this variable disappears from the listbox and database

3 views (last 30 days)
Aymen Liga
Aymen Liga on 6 Jun 2019
Commented: Geoff Hayes on 10 Jun 2019
hi
my problem is, I want to delete some data in the database that this data contains in the Access file, I want to delete it from the GUI
I want to select this variable in list box then click on the deleted button this variable disappears from the list and the database !
The second problem in listbox is not displaying all characters, but displaying only 6 characters

  0 Comments

Sign in to comment.

Accepted Answer

Geoff Hayes
Geoff Hayes on 9 Jun 2019
Aymen - you haven't indicated how you are creating your GUI (using GUIDE, programmatically, or with App Designer) so the general idea would be to do the following:
  1. create a callback for your delete button
  2. in the callback body, get the index/value of the selected item in the list (using the list box handle or object)
  3. using the cell array of list items (the record ids?) and the selected index, get the selected item
  4. remove the selected item from your cell array and update the list box with this modified cell array
  5. create the SQL statement to delete the record from your database
  6. execute the SQL statement
As for the numbers (record ids) being formatted inconsistently, you will need to show the code you are using to update the list items. (You are probably doing a conversion from integer to a string or something like that). If using num2str you may want to set the format as shown at formatSpec — Format of output fields.

  4 Comments

Show 1 older comment
Geoff Hayes
Geoff Hayes on 10 Jun 2019
Aymen - what is the data type for the n_m array? Is this a cell (?) array of strings or an array of numbers (double or integer type)?

Sign in to comment.

More Answers (0)