Adding data to Matlab GUI Table from a listbox

조회 수: 8 (최근 30일)
Jayesh Kavathe
Jayesh Kavathe 2011년 10월 26일
댓글: Aqilah Ahmad 2022년 6월 5일
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?

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 10월 26일
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
Nigussie
Nigussie 2014년 3월 4일
Hi, How can i put the entire columns' data of the gui table to a listbox using a push button.
Nigussie
Nigussie 2014년 3월 13일
I got the answer after some digging.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Amardeep
Amardeep 2011년 10월 26일
under the cell selection callback for the GUI table you can get the value from the listbox using the handles structure for the listbox.

Jayesh Kavathe
Jayesh Kavathe 2011년 10월 26일
Perfect. I am a totally GUI newbie and still I was able to get it working. Appreciate for your time and exact code. :)
I am using the "Push" Button.
  댓글 수: 1
Aqilah Ahmad
Aqilah Ahmad 2022년 6월 5일
Hi Mr Kavathe, do you mind to share your GUI coding?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by