Problem with changing visibility of pop-up list
조회 수: 2 (최근 30일)
이전 댓글 표시
The code below is a part of my program. In GUI, there are 4 pop-up lists and the code is used to change their visibility. The first one is always visible. First if sets the next 3 lists invisible, the second sets only last 2 invisible, third one sets last one invisible and fourth one sets all visible.
if strcmp(handles.ws,'Jedna')
set(handles.wsyg2, 'visible', 'off'); %line 392
set(handles.wsyg3, 'visible', 'off');
set(handles.wsyg4, 'visible', 'off');
% Update handles structure
guidata(hObject, handles);
elseif strcmp(handles.ws,'Dwie')
set(handles.wsyg2, 'visible', 'on');
set(handles.wsyg3, 'visible', 'off');
set(handles.wsyg4, 'visible', 'off');
% Update handles structure
guidata(hObject, handles);
elseif strcmp(handles.ws,'Trzy')
set(handles.wsyg2, 'visible', 'on');
set(handles.wsyg3, 'visible', 'on');
set(handles.wsyg4, 'visible', 'off');
% Update handles structure
guidata(hObject, handles);
elseif strcmp(handles.ws,'Cztery')
set(handles.wsyg2, 'visible', 'on');
set(handles.wsyg3, 'visible', 'on');
set(handles.wsyg4, 'visible', 'on');
% Update handles structure
guidata(hObject, handles);
end
The problem is that after, for example, setting all 4 lists visible and choosing values from them, it is impossible to go back: I can't choose to have only one visible. I get this error:
Error using set
Invalid handle
Error in SOI_projekt>ws_Callback (line 392)
set(handles.wsyg2, 'visible', 'off');
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in SOI_projekt (line 43)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)SOI_projekt('ws_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
Thanks for help.
댓글 수: 0
답변 (1개)
Jan
2021년 1월 16일
What is the purpose of:
% Update handles structure
guidata(hObject, handles);
For some unknown reasons the value of handles.wsyg2 has been overwritten or the corresponding object was deleted or replaced. Check this using the debugger:
dbstop if error
Then run the code again until it stops at the error. Now check the value of handles.wsyg2 .
If the corresponding object was deleted, this did not happen in the shown part of the code, but somewhere else.
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!