Setting edit text box visibility

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
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
Shanmukha priya V am 23 Dez. 2014
By the term 'it is not running', I meant that the expected output was not obtained. Everything was visible when i run the program. Nothing i specified was hidden.
I've tried if paired with strcmp and I'm getting the following error:
Error using ge_svm>range_SelectionChangeFcn (line 504)
Not enough input arguments.
Error in hgfeval (line 63)
feval(fcn{1},varargin{:},fcn{2:end});
Error in uitools.uibuttongroup/childAddedCbk>manageButtons (line 79)
hgfeval(cbk, source, evdata);
Error while evaluating uicontrol Callback
Error using ge_svm>range_SelectionChangeFcn (line 491)
Not enough input arguments.
Error in hgfeval (line 63)
feval(fcn{1},varargin{:},fcn{2:end});
Error in uitools.uibuttongroup/childAddedCbk>manageButtons (line 79)
hgfeval(cbk, source, evdata);
Error while evaluating uicontrol Callback
I got the same error while executing with switch case also.
Geoff Hayes
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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 22 Dez. 2014

Kommentiert:

am 26 Dez. 2014

Community Treasure Hunt

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

Start Hunting!

Translated by