How can i edit to an uitable's cell with only one click ;;;

6 次查看(过去 30 天)
hello, i create two uitables
DataX = cell(1,px);
DataY = cell(1,py);
when i fill the cells of the 1st uitable with my values and go to the next one, the 1st cell that i will choose to edit, i have to double click to edit.
My question is how can i edit only with one click, even at 1st or 2nd uitable
thanks in Advance. :-)

回答(1 个)

Joseph Cheng
Joseph Cheng 2014-10-1
You can try to do something like this
function Untitled()
f = figure
data = rand(3);
colnames = {'X-Data', 'Y-Data', 'Z-Data'};
t1 = uitable(f, 'Data', data, 'ColumnName', colnames, ...
'Position', [20 20 260 100],'ColumnEditable',[true true true true])
set(t1, 'CellSelectionCallback',{@activate});
data = rand(3);
colnames = {'X-Data', 'Y-Data', 'Z-Data'};
t2 = uitable(f, 'Data', data, 'ColumnName', colnames, ...
'Position', [20 140 260 100],'ColumnEditable',[true true true true])
set(t2, 'CellSelectionCallback',{@activate});
function activate(hobject,event)
uitable(hobject);
Probably some better way to implemented but for 5 min its not too bad and something you can build upon.
  3 个评论
Chrysovalantis Nikolaou
hi Joseph,
thank you for the so quickly answer but it doesn't solve my problem.
If you try to edit to the 1st uitable in any cell, and then go to edit to other uitable, the cell that you choose it's getting blue and you have to click for second on it so as to edit...
this is happening only at the first cell of the uitable, next you just click and edit...
that is what i want to avoid. Am i clear ;;;
Joseph Cheng
Joseph Cheng 2014-10-2
I concede that yes the other table stays highlighted. I'm sure you could figure out how to select. Simple enough to test out to unset, however after clicking to the other box you do not need to double click. just type in anything after the first click

请先登录,再进行评论。

类别

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