Delete a selected row in a uitable
4 views (last 30 days)
Hi, I have this script for delete a certain row wich is selected by the user:
D(Index.Indices(:,1), :) = ;
When I perform a selection and first time push the button to delete the row, i get this error:
Attempt to reference field of non-structure array.
Error in Generator_v1>pushbutton5_Callback (line 171)
a = D(Index.Indices(:,1), :);
Error in gui_mainfcn (line 95)
Error in Generator_v1 (line 42)
Error in @(hObject,eventdata)Generator_v1('pushbutton5_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
After the first attempt with this error everything works perfect, when I made a second selection it perform the action with no error.
What could that be?
Voss on 29 May 2022
Move this line to the OpeningFcn:
Having that line in the pushbutton's Callback function means that the table's CellSelectionCallback is not set until after the pushbutton's Callback is executed at least once, which in turn means that the table has empty UserData even though a selection may have been made, because there was no CellSelectionCallback defined at the time the selection was made.