I asked previously about setting the listbox properties so that when a list of files is loaded, the first one is not selected. I was told there was no way around that, which basically concluded as well. However, after chance, I determined that if I clicked in the empty box, then loaded the file names in the box, none of them would be selected. Is there anyway to "fake" a mouse click? It only happens if I click, or double click inside the listbox. I was trying something along the lines of:
set(handles.figure1,'SelectionType','open')
I tried that inside of (files is the listbox tag-this function executes on selection change in filebox:
function files_Callback(hObject, eventdata, handles)
Any hope with this?

 채택된 답변

per isakson
per isakson 2013년 1월 25일
편집: per isakson 2013년 1월 25일

0 개 추천

I have trouble understanding your question. Isn't there one negation too many? However,
set( listbox_handle, 'Value', [] )
  • regarding "none selected" interactively I've failed an added the string "- none -" at the top of the list. Selecting that row triggers
set( listbox_handle, 'Value', [] )
.
With R2012a on Windows 7

댓글 수: 3

In R2012a and later on OS-X, set( listbox_handle, 'Value', [] ) when String property is non-empty, results in
Warning: single-selection listbox control requires a scalar Value
Control will not be rendered until all of its parameter values are valid
@Walter: Does the warning appear, when multi-selection is enabled?
set(listbox_handle, 'Min', 0, 'Max', 2, 'Value', [])
Jared
Jared 2013년 1월 25일
I can confirm that set(listbox_handle, 'value',[]) does work with multiselect enabled.
Thanks

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

추가 답변 (2개)

Jeffery Devereux
Jeffery Devereux 2019년 5월 13일

2 개 추천

Try this:
set(app.ListBox, 'Value', { })
Walter Roberson
Walter Roberson 2013년 1월 25일

0 개 추천

R2012a on OS-X Lion, I do not get that behavior. If I create a uicontrol style listbox, at the command line, then click in it, and then set() its String, I get
Warning: single-selection listbox control requires a scalar Value
Control will not be rendered until all of its parameter values are valid

댓글 수: 2

Walter Roberson
Walter Roberson 2013년 1월 25일
Ah, just a thought; this is only a problem if multi-select is not on. Perhaps you could take advantage of that?
Jared
Jared 2013년 1월 25일
I do have multi-select enabled, so maybe there is some hope... But like I said in the other question, this isn't a huge deal if I can't get it to work.

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

카테고리

도움말 센터File Exchange에서 Entering Commands에 대해 자세히 알아보기

태그

질문:

2013년 1월 25일

댓글:

2019년 6월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by