MATLAB Answers

Why cant i click my checkbox created in UItable in Matlab GUIDE?

5 views (last 30 days)
I have a Uitable created where in the 6th column you have a checkbox.I am not able to click the tickbox.Why is that? and also how do i delete a row in my Uitable after clicking that check box? I am attaching my code and picture of the table.Any help will be appreciated
function TerrainGUI_v2_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to TerrainGUI_v2 (see VARARGIN)
type_environment ={'Segm', 'Arc' ,'Circuit', 'Intersection' ,'Round', 'Spline'};
type_Location ={'City', 'Country' ,'Highway'};
slope = [{''}];
len_Portions = {};
radius_Portions = [''];
authorised = [{false}] ;
tabledata =[type_environment(1) type_Location(1) len_Portions slope radius_Portions authorised]; % A condition has to be added that if i add a straight line i should disable the radius of portions
%Column_to_affect = 5;
% tabledata (:,Column_to_affect) = cellfun(@num2str, tabledata(:,Column_to_affect), 'uniform', 0);
columnname ={'Environment','Location','Length of Portions or Angle of turn','Slope','Radius of turn','Authorised'};
columnformat = {type_environment,type_Location,'numeric','numeric','numeric','logical'};
columneditable = [true true true true true true];
set(handles.table_Tracks,'ColumnName',columnname,'ColumnWidth','auto','Data',tabledata,'ColumnFormat', columnformat,'ColumnEditable', columneditable,'RowName',[], 'BackgroundColor',[.7 .9 .8],'ForegroundColor',[0 0 0]);
% Choose default command line output for TerrainGUI_v2
handles.output = hObject;
% Update handles structure guidata(hObject, handles); end


Sign in to comment.

Accepted Answer

Geoff Hayes
Geoff Hayes on 24 Apr 2018
sachin - please ensure that your checkbox column is editable. As for deleting a row, are you deleting the row where you check the box? That may be possible. You can add a CellEditCallback to your GUI that does something like
function uitable1_CellEditCallback(hObject, eventdata, handles)
row = eventdata.Indices(1);
col = eventdata.Indices(2);
if col == 1
data = get(hObject,'Data');
data(row,:) = [];
Try the above and see what happens!


sachin narain
sachin narain on 24 Apr 2018
Hey Geoff.Waiting for a rsponse from a long time.Yes it is editable ,as you can see there are 6 columns and 6th one is the checkbox column 'Authorised' and i have also made it editable by putting column format as true.But for deleting a row i want my checkbox to work because as soon as the user clicks the checkbox i will be able to delete the row
Geoff Hayes
Geoff Hayes on 25 Apr 2018
sachin - that is strange behaviour and it isn't clear to me why the sixth column is not editable. Have you tried editing the table (i.e. setting the columns) in GUIDE rather than programmatically?
sachin narain
sachin narain on 25 Apr 2018
Thanks for responding again Geoff.No i havent tried that.i will try it and get back to you.Thanks again

Sign in to comment.

More Answers (0)

Sign in to answer this question.