Listbox... How to make matches of two, is it possible???

3 次查看(过去 30 天)
Hi everybody!!
I'd like to create two listboxes that scrolls with the same scrollbar... Is it possible?? My aim is to insert two arrays that are related to each other. I can't use cellarrays because of my code...
Can I match two listboxes like two columns of a table??
Or if someone know how to use uitable to set rows and columns starting from arrays length, can you answer here: http://www.mathworks.it/matlabcentral/answers/26624-uitable-how-to-set-number-of-rows-columns ?

回答(2 个)

Walter Roberson
Walter Roberson 2012-1-20
If it could be done to synchronize the scrolling of two listboxes, it would have to be at the Java level. Scrolling does not (as far as I know) create an event that could be used to trigger the transfer of the scroll information to another box.
At any particular point, you can get() or set() the ListBoxTop property, which is the current scrolling amount. You just don't get notified that it has changed. Though I suppose you could waitfor() the property to be changed; I am not sure if that would work, but it might.
If you do not mind an explicit user action to request synchronization, you could set the ButtonDownFcn property of the listbox, which the user would activate by right-clicking (left clicking would be for selecting the entry still); that would give you notice to set the ListBoxTop to be the same.

Sean de Wolski
Sean de Wolski 2012-1-20
You could possibly add a post-set listener to the ListBoxTop property that updates the other one whenever the first one is changed.
doc addlistener
  2 个评论
Jethro
Jethro 2012-1-21
So, If I add addlistner, every time I select something from the first list box (so I can new the selected value), the second box scrolls at the line corresponding to my value???
Walter Roberson
Walter Roberson 2012-1-21
addlistner gives you an opportunity to have a routine called when an event occurs. The routine you designate would have to check the ListBoxTop of the list being scrolled, and would have to set() the ListBoxTop of the other list.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by