find handle to "uitable" already placed in figure?

2 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by