フィルターのクリア

uitable's cells as a readonly

20 ビュー (過去 30 日間)
Mtlb Usr
Mtlb Usr 2011 年 3 月 1 日
Hi,
I would like to know how I can set several cells of a uitable like a readonly effect.
Thanks
regards.
  2 件のコメント
Sarah Wait Zaranek
Sarah Wait Zaranek 2011 年 3 月 1 日
Would you like them to be not editable? Did you already try the "ColumnEditable" property?
Mtlb Usr
Mtlb Usr 2011 年 3 月 2 日
Hi Sarah,
Yes,you're right.
No, I have got a old version of matlab. I think that in this version the similar property is "Editable", but I'm not sure.
regards

サインインしてコメントする。

採用された回答

Mtlb Usr
Mtlb Usr 2011 年 3 月 3 日
Hi,
I have tested with this example but I can't set the column that I want.
E.g: hT=uitable(...); %To set the 1st col as a noneditable. set(hT,'Editable',[false true true]);
The issue is that one error appears saying that the parameter value must be scalar...
How can I resolve it?
thanks
regards
  2 件のコメント
Oleg Komarov
Oleg Komarov 2011 年 3 月 3 日
Unfortunately I see the general problem but I don't have R2007b, don't see how I can help you.
* You may try to update your current version, if feasible
* Use this submission http://www.mathworks.com/matlabcentral/fileexchange/11201
* This thread may be useful: http://www.mathworks.com/matlabcentral/newsreader/view_thread/165066
* And finally this migration note for uitable from 2007b to 2008a: http://www.mathworks.com/help/techdoc/uitools_csh/error_pages/uitable_errorpage.html
Mtlb Usr
Mtlb Usr 2011 年 3 月 3 日
Hi Oleg,
Thank you for u answer.
I will try to get a new matlab.
regards

サインインしてコメントする。

その他の回答 (1 件)

Oleg Komarov
Oleg Komarov 2011 年 3 月 1 日
Here an example that allows you to set as non editable just some cells of a column:
function exampleGUI
f = figure('Position',[200 200 400 150]);
dat = rand(3);
cnames = {'X-Data','Y-Data','Z-Data'};
rnames = {'First','Second','Third'};
t = uitable('Parent',f,'Data',dat,'ColumnName',cnames,...
'RowName',rnames,'Position',[20 20 360 100],...
'ColumnEditable',[true true true],'CellEditCallback',@t_ced);
function t_ced(varargin)
% Retrieve info on edited cell
edC = varargin{2};
% Transform subscipts of selected cell into idx
idx = sub2ind(size(dat),edC.Indices(1),edC.Indices(2));
% If idx falls into 5-9 range set back previous value
if ismember(idx, 5:9)
data = get(t,'data');
data(idx) = edC.PreviousData;
set(t,'data',data)
end
end
end
Save it as exampleGUI and run it. Only cells 5-9 are non editable.
  3 件のコメント
Oleg Komarov
Oleg Komarov 2011 年 3 月 2 日
Change ColumnEditable to Editable if that's the case for your version.
Mtlb Usr
Mtlb Usr 2011 年 3 月 3 日
Hi Oleg,
How can I use Editable property?
I have got r2007b version of matlab.
thanks
regards

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by