필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
sachin narain
sachin narain 2018년 4월 24일
댓글: sachin narain 2018년 4월 25일
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

채택된 답변

Geoff Hayes
Geoff Hayes 2018년 4월 24일
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
Geoff Hayes
Geoff Hayes 2018년 4월 25일
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 2018년 4월 25일
Thanks for responding again Geoff.No i havent tried that.i will try it and get back to you.Thanks again

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by