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

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,:) = [];
set(hObject,'Data',data);
end
Try the above and see what happens!
  3 Comments
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)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!