Can i set all text boxes to their default value by using only one command
古いコメントを表示
I 'm using this command to set textbox to its default value I have 17 text boxes in my GUI. I want to reset all of them by using command only one time instead of calling this 17 times. Is it possible?
set(handles.text1, 'string', 'default');
採用された回答
その他の回答 (2 件)
Jos (10584)
2016 年 6 月 14 日
This task would be utterly trivial if you had put the handles to the boxes into an array on creation!
handles.text(1) = ..
handles.text(2) = ..
...
set(handles.text,'String','') ;
1 件のコメント
Yes, this is the best answer! When graphics handles are explicitly stored and accessed then the code will be clearer, faster, and more robust.
Avoid the problem by writing better code in the first place:
Walter Roberson
2016 年 5 月 17 日
In MATLAB, textbox objects do not have a default value; or if they do, it is the empty string. textbox objects are also used for output, not for input; do you perhaps mean editbox?
set( findall( ancestor(handles.edit1, 'figure'), 'style', 'edit'), 'string', 'WhatEverYouWant')
3 件のコメント
mania online
2016 年 5 月 18 日
mania online
2016 年 5 月 18 日
Walter Roberson
2016 年 5 月 18 日
set( findall(0, 'style', 'edit'), 'string', '')
The default value of a uicontrol of style edit is the empty string.
カテゴリ
ヘルプ センター および File Exchange で Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!