Tables in GUI / GUIDE

3 次查看(过去 30 天)
John
John 2012-3-8
Ok, I followed a video by Doug Hull on basics for Tables in GUIDE: http://blogs.mathworks.com/pick/2008/05/07/matlab-basics-adding-a-table-to-a-gui/
and made the assumption that to set the data in a table you can do:
function Table_CellEditCallback(hObject, eventdata, handles)
info = [1 2 3;4 5 6];
set(hObject,'data',info);
and it worked...
I then added some complexity, I get some appdata and set it to be info and the set call broke. Apparently there is no 'data' property and I get the following:
Error using hg.figure/set The name 'data' is not an accessible property for an instance of class 'figure'.
I have rolled back the code to when it was working, restarted MATLAB and it's still broken. I have no idea why it has stopped working.
Help Please!

采纳的回答

Sean de Wolski
Sean de Wolski 2012-3-8
It means that the figure is calling this instead of the table. Thus hObject is the figure handle (the source calling the callback) instead of the table handle and that's why you're seeing the error.
To fix it, specify the handle to the table, something like:
set(handles.Table,'data',info)
Please feel free to leave an angry message for Doug too ;)

更多回答(1 个)

John
John 2012-3-8
Boom! Once again you've helped me out! :@ Doug! So useful but also can be so confusing!
Cheers

类别

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