Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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

Respuesta aceptada

Walter Roberson
Walter Roberson el 27 de Abr. de 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 comentarios
Walter Roberson
Walter Roberson el 27 de Abr. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by