-1

我在访问 Matlab uitable 中的复选框时遇到问题。我在 Matlab GUI 中有一个表,其中有一列复选框。单击复选框时,我想打开特定的 pdf 文件。但我在 uitable 中找不到复选框的回调。希望问题是陈述清楚。

提前致谢, 阿比鲁普

4

1 回答 1

1

CellEditcallback为您的桌子创建自己的。

举个例子:

function testcode
% Initialize a basic GUI
h.myfig = figure;

% Initialize a dummy table
cnames = {'a','b'};
cformat = {'char', 'logical'};
rnames = {'1','2'};
mydata = {'firstfile', false; 'secondfile', false};
h.mytable = uitable( ...
    'Parent', h.myfig, ...
    'CellEditCallback', @boxchecked, ...
    'ColumnFormat', cformat, ...
    'ColumnName', cnames, ...
    'ColumnEdit', true, ...
    'RowName', rnames, ...
    'Data', mydata ...
    );

guidata(h.myfig,h); % Store handles for later
end

function boxchecked(hObject,eventdata)
h = guidata(hObject); % Retrieve handles
% Your code here
end

在函数中设置断点boxchecked并查看提供给您的数据eventdata(另请参阅通用回调文档)。三个重要的字段是Indices字段,它为您提供已编辑并导致回调执行的单元格,以及PreviousDataNewData字段,它为您提供已编辑单元格的前后值。

您还需要检查编辑的单元格是否是复选框(CellEditCallback对表格中的单元格进行任何更改时执行)。根据这些数据,决定您要采取的行动。

于 2014-11-18T19:00:29.030 回答