How to add remove uicontrol programmatically

13 ビュー (過去 30 日間)
Neville
Neville 2013 年 10 月 19 日
コメント済み: Neville 2013 年 10 月 22 日
I need to make 1 button tha will create the Edit Text control and another button to remove it. I created the Edit Text using the code below:
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
eth = uicontrol('Parent', handles.uipanel5,'Style','edit',...
'String','Enter your name here.',...
'Position',[30 50 130 20]);
I need help with the code to remove it. Thanks.

回答 (2 件)

Walter Roberson
Walter Roberson 2013 年 10 月 19 日
A lot of the time you will find that setting Visible off on the control is better. Have your code set Visible 'on' when you want it to appear.
When you have a handle, you can use delete() of the handle to remove the control.

Neville
Neville 2013 年 10 月 20 日
Follow-up question:
Using the code given, how can i access the eth handle if i want to use it on another callback?
I'm very new to matlab i'm not really familiar with handles.
  2 件のコメント
Neville
Neville 2013 年 10 月 22 日
Thanks Walter.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by