Gui Table With Editable Column Names

4 ビュー (過去 30 日間)
Brendan
Brendan 2012 年 8 月 10 日
コメント済み: Walter Roberson 2017 年 5 月 8 日
Hi All
I am making a GUI that has a table in it. I want the user to be able to click on the column names and edit them just like they can manually edit data in the table. However, using guide and the property inspector I cant figure out a way to make the column headers editable. Has anyone done this before/ know how to do this. Thanks
PS. I know I could make an editable textbox separately and use that to feed names to the column headers but my gui is tight on space and I want to avoid doing this if at all possible.

回答 (3 件)

Matt Fig
Matt Fig 2012 年 8 月 10 日
You could do something like this to save room:
function [S] = GUI_table()
% Save space and allow user to change column names.
S.fh = figure('units','pixels',...
'position',[400 400 380 200],...
'menubar','none',...
'name','GUI_table',...
'resize','off',...
'numbertitle','off');
S.tb = uitable('position',[5 5 370 190],...
'columnwidth',{80,80,80,80},...
'columnname',{'A','B','C','D'},...
'rowname',{'1','2','3','4','5','6'});
S.pb(1) = uicontrol('style','push',...
'units','pix',...
'position',[10 172 20 20],...
'string','?',...
'fontsize',10,...
'fontweight','bold',...
'callback',{@pb1_call},...
'tooltip','Change Column Names',...
'backgroundcolor',[.1 .25 .25],...
'foregroundcolor','w');
function [] = pb1_call(varargin)
% Callback for the pushbutton.
prompt={'Column 1','Column 2','Column 3','Column 4'};
name='Enter column names';
numlines=1;
defaultanswer=get(S.tb,'columnname');
options.Resize='on';
options.WindowStyle='modal';
options.Interpreter='tex';
A=inputdlg(prompt,name,numlines,defaultanswer,options);
set(S.tb,'columnname',A)
end
end

Sean de Wolski
Sean de Wolski 2012 年 8 月 10 日
編集済み: Sean de Wolski 2012 年 8 月 10 日
No this is not possible. Your workaround with an edit box sounds like a good option.

Ahmed raafat
Ahmed raafat 2017 年 5 月 7 日
set(handles.uitable_tag,'ColumnName',{'any' 'name' 'you' 'want'})
  1 件のコメント
Walter Roberson
Walter Roberson 2017 年 5 月 8 日
That changes the column names through the program, but does not give the user the ability to click on the column names and edit them.

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

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by