Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Stop uitable from appending to cell when you type

1 回表示 (過去 30 日間)
Jeremy
Jeremy 2019 年 7 月 17 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
In uitable with a table as data, if you single click a cell and start typing, it will append to the existing extry with what you type. Any idea how I can get it to behave like Excel, where you single click a cell, start typing, it will replace what was there with what you type?
f = uifigure;
tData = table(0, 0, 0);
uit = uitable(f, 'Data', tData, 'ColumnEditable', [true true true]);

回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 7 月 17 日
Use the uitable cell selection callback. When the callback fires, look at the position indicated in the event data, and set that entry to be empty -- so clicking on an entry erases the entry, leaving you positioned to type in new content.
Note that this requires that the entries are all character and not numeric, as you cannot set a numeric entry to pure whitespace with this technique.
  1 件のコメント
Jeremy
Jeremy 2019 年 7 月 17 日
I tried that approach, and it does work to be able to replace the entry with a single click. Unfortunately it doesn’t leave open the possibility of editing the current contents rather than replace it. Ideally, typing over a single click on the cell will replace the current cell contents, but I’d like to still be able to double click on the cell and edit what’s already there, like Excel. Not sure how to go about that, though.

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by