Setting edit text box visibility
6 次查看(过去 30 天)
显示 更早的评论
Sir, I've two radio buttons inside a buttongroup. If one is pressed, then the visibility of a set of edit box and static text box should be on and similarly, if the other is pressed, the corresponding set should be visible and first set should be invisible. The part of my code containing this is:
% --- Executes when selected object is changed in range.
function range_SelectionChangeFcn(hObject, eventdata, handles)
% hObject handle to the selected object in range
% eventdata structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty if none was selected
% NewValue: handle of the currently selected object
% handles structure with handles and user data (see GUIDATA)
switch get(eventdata.NewValue,'Tag') % Get Tag of selected object.
case 'cont'
set(handles.text5,'Visible','on')
set(handles.text6,'Visible','on')
set(handles.a1,'Visible','on')
set(handles.b1,'Visible','on')
set(handles.text7,'Visible','off')
set(handles.text8,'Visible','off')
set(handles.text9,'Visible','off')
set(handles.text10,'Visible','off')
set(handles.a2,'Visible','off')
set(handles.b2,'Visible','off')
set(handles.c2,'Visible','off')
set(handles.d2,'Visible','off')
case 'discont'
set(handles.text5,'Visible','off')
set(handles.text6,'Visible','off')
set(handles.a1,'Visible','off')
set(handles.b1,'Visible','off')
set(handles.text7,'Visible','on')
set(handles.text8,'Visible','on')
set(handles.text9,'Visible','on')
set(handles.text10,'Visible','on')
set(handles.a2,'Visible','on')
set(handles.b2,'Visible','on')
set(handles.c2,'Visible','on')
set(handles.d2,'Visible','on')
end
Here a1,b1,a2,b2,c2,d2 are tags of edit boxes and text 5 to text 10 are tags of static text boxes. This was working perfect one time. But when I run the program after a few days, it is not running. But I didn't edit anything in this code.
4 个评论
Geoff Hayes
2014-12-26
I can't reproduce your error using something similar to the code that you have provided, so you may want to attach more code so that we can get a better idea of the problem and how best to go about and solve it.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!