find handle to "uitable" already placed in figure?

조회 수: 7 (최근 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 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