find handle to "uitable" already placed in figure?
2 views (last 30 days)
Show older comments
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 Comments
Ingrid
on 23 Jun 2015
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)
Accepted Answer
Joseph Cheng
on 23 Jun 2015
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 Comments
Joseph Cheng
on 23 Jun 2015
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)
More Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!