Cell select callback on uitable
28 views (last 30 days)
Show older comments
Jason
on 17 Dec 2014
Commented: Julius Rinaldi Simanungkalit
on 7 Sep 2020
I have a uitable that I want to be able to select a cell with a mouse, and the value in that cell be put in an edit box. Under the CellSelectionCallback, I have the following code.
However, it attempts to run (and crash) when the contents of the uitable change. How can I only implement this when the mouse selects that cell?
function uitable1_CellSelectionCallback(hObject, eventdata, handles)
% hObject handle to uitable1 (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.CONTROL.TABLE)
% Indices: row and column indices of the cell(s) currently selecteds
% handles structure with handles and user data (see GUIDATA)
%handles=guidata(source);
handles.currentCell=eventdata.Indices;
guidata(gcf,handles);
handles=guidata(gcf);
Indices=handles.currentCell;
data=get(handles.uitable1,'Data');
data=data(Indices(1),Indices(2));
set(handles.editNum,'String', data);
5 Comments
Geoff Hayes
on 19 Dec 2014
Cool, Jason. Consider making your solution (in the above comment) as an answer to your question.
Accepted Answer
Jason
on 22 Dec 2014
Edited: Jason
on 22 Dec 2014
1 Comment
Julius Rinaldi Simanungkalit
on 7 Sep 2020
this method does work, but only to display one cell only. can you help me how to display one table row, by just clicking. Please help me :)
More Answers (0)
See Also
Categories
Find more on Function Creation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!