Adding data to Matlab GUI Table from a listbox
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Jayesh Kavathe
am 26 Okt. 2011
Kommentiert: Aqilah Ahmad
am 5 Jun. 2022
I have a Matlab table taking different type of input from user. Is there any way I can drag a single variable from a displayed listbox into the current active cell?
If not, can I "Add" a button to my interface, which when clicked, will populate the current cell with selected variable from the list box?
0 Kommentare
Akzeptierte Antwort
Fangjun Jiang
am 26 Okt. 2011
It can be done as Amardeep suggested. But I think adding a push button is better as it avoids accidental operation when clicking on the table.
In the uitable CellSelectionCallback, you need to save the indices of the selected cell
setappdata(hObject,'CurrentCell',eventdata.Indices);
In the push button callback, you need to read the list box and then assign the new value. The following code assumes the uitable contains cell data and all columns are editable.
Indices=getappdata(handles.uitable1,'CurrentCell');
Data=get(handles.uitable1,'Data');
List=get(handles.listbox1,'string');
NewData=List{get(handles.listbox1,'value')};
Data{Indices(1),Indices(2)}=NewData;
set(handles.uitable1,'Data',Data);
2 Kommentare
Nigussie
am 4 Mär. 2014
Hi, How can i put the entire columns' data of the gui table to a listbox using a push button.
Weitere Antworten (2)
Amardeep
am 26 Okt. 2011
under the cell selection callback for the GUI table you can get the value from the listbox using the handles structure for the listbox.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!