MATLAB Answers

how can i change the Color of the Row (uitable) when if==0? Die farbe der reihe im IUtable soll sich öndern wenn if ==0

12 views (last 30 days)
Torsion27
Torsion27 on 10 Apr 2018
Edited: Torsion27 on 10 Apr 2018
function pushbutton2_Callback(hObject, eventdata, handles)
global pushbutton
[num,txt,raw]= xlsread(uigetfile ({'.xlsx'}))
anzahl_kriterien = size([raw],1)
kriterium = cell(anzahl_kriterien);
for i=1:anzahl_kriterien
kriterium{i,1} = raw(i)
end
tabledata = [num2cell(true(length(raw),1)),raw];
set(handles.uitable3, 'data',tabledata)
setappdata(handles.uitable3,'RawTableDat',raw)
function uitable3_CreateFcn(hObject, eventdata, handles)
hObject.ColumnFormat = {'logical',[]};
hObject.ColumnEditable = logical([1 0]);
function uitable3_CellEditCallback(hObject, eventdata, handles)
tabledata=get(handles.uitable3,'Data');
spalte1=tabledata(:,1)
zeilenanzahl=length(tabledata);
for j = 1:length(tabledata) %für zeile 1 bis ende
for i=2
if (tabledata{j,1}==0)
uitablehandles=findobj(handles.uitable3);
set(uitablehandles,'BackgroundColor',[1 0 0]);
elseif (tabledata{j,1}==1)
uitablehandles=findobj(handles.uitable3);
set(uitablehandles,'BackgroundColor',[0 1 0]);
end
end
end

  0 Comments

Sign in to comment.

Answers (0)

Sign in to answer this question.