Setting edit text box visibility
Ältere Kommentare anzeigen
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 Kommentare
Geoff Hayes
am 22 Dez. 2014
What do you mean by it is not running? Are the controls no longer being hidden, or is it something else? Put a breakpoint at the first line of your callback (above) and launch your GUI. What is get(eventdata.NewValue,'Tag') and does it match with cont or discont?
Note that you may want to consider using an if/elseif paired with a strcmpi rather than a switch block.
Shanmukha priya V
am 23 Dez. 2014
Shanmukha priya V
am 23 Dez. 2014
Geoff Hayes
am 26 Dez. 2014
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.
Antworten (0)
Kategorien
Mehr zu Interactive Control and Callbacks finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!