I finally found the solution here:
How to edit dynamically generated checkboxes with uitable from the GUIDE environment in MATLAB?
2 次查看(过去 30 天)
显示 更早的评论
Hi Guys,
I would like to create a table with as many rows with checkboxes as the user wants to create. I did so with the 'uitable-object' in the Matlab GUIDE environment. The necessary checkboxes are created in the Opening function of the GUI.
Unfortunately the checkboxes added are not editable...i cannot check or uncheck them. Here is the opening function of the GUI.
function Try1_bus_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for Try1_bus
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
hMainGui = findobj('Tag','bus_') %get the GUI figure
handlesGui_bus = guidata(hMainGui)
usernumber=30 %number buses in the network
display(handles)
for i=1:usernumber
if i==1
newRow={[1] ['Bus', num2str(i)]}
newData= [newRow]
set( handlesGui_bus.uitable_,'Data',newData)
end
oldData = get( handlesGui_bus.uitable_,'Data')
newRow={[1] ['Bus', num2str(i)]}
newData = [oldData; newRow];
set( handlesGui_bus.uitable_,'Data',newData)
end
How can i make the checkboxes editable? the first if-nesting i had to do somehow because otherwise the table would have looked like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/149376/image.png)
Strangely I couldnt remove this first 4 checkboxes you see on the picture with GUIDE. Those 4 checkboxes in the beginning still were editable but all the ones that i added with the code above were uneditable.
I would be very glad for your help! The fig and m files are attached!
Best regards, John
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!