MATLAB Answers

0

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

Asked by Aymen Liga on 6 Jun 2019
Latest activity Commented on by 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.

1 Answer

Answer by Geoff Hayes
on 9 Jun 2019
 Accepted Answer

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
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)?
Try converting each element in the array to a string using num2str.

Sign in to comment.