Get selected value instantly from a listbox without clicking it first

조회 수: 2 (최근 30일)
Jan w
Jan w 2016년 12월 10일
댓글: Jan w 2016년 12월 17일
I have a listbox on my gui. When I start the programm the first value in the listbox is selected. But the programm only registers a value when you click it first. So is there a way the programm can start my calculation without having to click the first option in the listbox?
A quick fix is to add the command to the OpeningFcn
listbox_Callback(handles.listbox, [], handles);
The problem is: This fix works fine for one listbox, but I have 3 on my gui. So when i add 3 of these commands to my openingfunction i get the error:
Reference to non-existent field
Any ideas how i can fix it?

채택된 답변

Image Analyst
Image Analyst 2016년 12월 10일
As long as you filled up your listbox somehow, either in GUIDE or your OpeningFcn(), you can get any item in it without having to have the user click on one. For example to get the second item in listbox #3:
allItemsInListbox3 = handles.listbox3.String; % Get all items from listbox3.
itemNumber2 = allItemsInListbox3{2}; % Extract only the second item from listbox3.
  댓글 수: 5
Walter Roberson
Walter Roberson 2016년 12월 15일
What does it mean to "get the variable of the list value" ?
Jan w
Jan w 2016년 12월 17일
I just wanted the value not the string of the listbox. Image Analyst solved my problem. Thanks! :)

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

추가 답변 (0개)

카테고리

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