find handle to "uitable" already placed in figure?

9 ビュー (過去 30 日間)
Marco
Marco 2015 年 6 月 23 日
コメント済み: Joseph Cheng 2015 年 6 月 23 日
Hello, I programmatically created a figure, and in a called function added programmatically an "uitable" to the figure. After having returned from the uitable creating function, I would like to access the uitable once more in order to add another data row to it. It alternatively could also be a possibility to just delete the uitable completely and replace it by a new one. However, for both options I would need to first find the handle to the uitable. In similar cases, for instance for finding access to an Annotation TextBox again, I could use the "findall" command and then dig in the handles output for my handle of interest:
handles = findall(gcf,'Type','TextBox');
But, I cannot find any trace to a handle of my uitable which is displayed in the figure, not even from screening the full output of
handles = findall(gcf)
How do I query for the handle of my uitable, please?
  2 件のコメント
Ingrid
Ingrid 2015 年 6 月 23 日
when you create the gui programtically, why would you want to use something like findall? Can you not just store the handle when you create the uitable (and likewise the textbox)
Marco
Marco 2015 年 6 月 23 日
It is because I want to dynamically update an existing figure, i.e. saved as *.fig the day before. I can dynamically update what is plotted, also the legend or an annotation textbox, but got stuck in accessing the already existing uitabel. Actually, I only use uitable because I did not find any other way to display a nicely formatted table showing some results in the figure. If there would be any alternative available, I am open to move to it. But, designing my own table in an Annotation Textbox was a nightmare, therefore I skipped that option, by now.

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

採用された回答

Joseph Cheng
Joseph Cheng 2015 年 6 月 23 日
I'm not sure why you're having a hard time finding the uitable handle since you've gave an example of finding the textbox handles. Maybe my quick test sheds some insight that i can't see where you're going wrong.
f = figure;
data = rand(3);
colnames = {'X-Data', 'Y-Data', 'Z-Data'};
uitable(f, 'Data', data, 'ColumnName', colnames, ...
'Position', [20 20 260 300])
%displayed ans is the uitable handle
uitablehandle = findall(f,'type','uitable')
savefig(f,'uitabletestfig.fig')
txt = uicontrol('Style','text',...
'Position',[20 350 120 20],...
'String','countdown till closed');
tic
while toc<5
set(txt,'string',['countdown till closed: ' num2str(5-round(toc))])
pause(.01)
end
%%close all things and clear workspace
clear all;
close all;
uiopen('uitabletestfig.fig',1)
uitablehandle = findall(gcf,'type','uitable')
uitabledata = get(uitablehandle,'Data');
set(uitablehandle,'Data',repmat(uitabledata,3,1))
  2 件のコメント
Marco
Marco 2015 年 6 月 23 日
編集済み: Marco 2015 年 6 月 23 日
Thanks a lot!!!
[EDIT] Well, I just didn't got the idea to once try out to search for 'type,'uitable' , after no uitable becomes listed in the output from the findall command. The keyword 'textbox' does show up, though. You wouldn't know about any list with possible keywords defining a 'type'? I mean, for the next time running into such trouble?
Joseph Cheng
Joseph Cheng 2015 年 6 月 23 日
well... from what i gather from using findall it looks for a string compare under the type "parameter" (so its as if you wrote a loop to check each figure children for its type and return when the types match)

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

その他の回答 (0 件)

カテゴリ

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