Effacer les filtres
Effacer les filtres

In GUI, how to obtain table data after editing its content ?

1 vue (au cours des 30 derniers jours)
Harsha M V
Harsha M V le 27 Avr 2018
Commenté : Harsha M V le 23 Mai 2018
I'm generating table after pressing push_button:
function pushbutton1_Callback(hObject, eventdata, handles)
a = 3;
b = str2num(get(handles.edit2,'String'));
data = cell(1,b);
data(:) = {''};
h1 = uitable('Parent', handles.uipanel1, 'FontSize', 10, 'Position', [10 100 400 60], 'RowName',{'Gene'}, 'ColumnWidth', {60}, 'ColumnEditable', true, 'Data', data)
Now, after changing the cell data in GUI, by pressing another push_button, how do I get the new updated table data ?
Thanking You,
Harsha

Réponse acceptée

Walter Roberson
Walter Roberson le 27 Avr 2018
You need to find the uitable somehow, and then get() its Data property.
There are multiple ways of doing that. One would be to write to handles.h1 instead of h1, and then to do
guidata(hObject, handles);
so that the handle of the table got written into the handles data structure.
Another way would be to give the uitable a Tag property, and later findobj() based on the Tag.
  3 commentaires
Walter Roberson
Walter Roberson le 27 Avr 2018
h1 = uitable('Parent', handles.uipanel1, 'FontSize', 10, 'Position', [10 100 400 60], 'RowName',{'Gene'}, 'ColumnWidth', {60}, 'ColumnEditable', true, 'Data', data, 'Tag', 'panel1');
Later:
h1 = findobj(0, 'tag', 'panel1')
"How to write to handles.h1, when table is not created in GUIDE. "
Your code
function pushbutton1_Callback(hObject, eventdata, handles)
implies that you either used GUIDE to create the overall GUI, or else that you wrote all of the GUI yourself but decided to use the same idea of the handles structure. In either of those cases, you would do
handles.h1 = uitable('Parent', handles.uipanel1, 'FontSize', 10, 'Position', [10 100 400 60], 'RowName',{'Gene'}, 'ColumnWidth', {60}, 'ColumnEditable', true, 'Data', data);
guidata(hObject, handles);
Once you had done that, in any later callbacks that pass in handles, you would use
handles.h1
to get to the handle.
Harsha M V
Harsha M V le 23 Mai 2018
Thank you.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by