Thread Subject: make two listboxes scroll at same time

Subject: make two listboxes scroll at same time

From: Johnathan

Date: 1 Jun, 2009 09:59:02

Message: 1 of 3

I would like to cause two listboxes to scroll in unison. Can I do this?

Thanks
--John

Subject: make two listboxes scroll at same time

From: Johnathan

Date: 1 Jun, 2009 19:21:01

Message: 2 of 3

Maybe I should clarify. What I am really trying to do is a selectable table in my gui. I know that the newest versions have uitable, but I am still using R2007a. I would really prefer to use the old, standard uicontrols anyway because the computers that this will be used on probably won't have the newest versions of matlab either.

I would like to place two listboxes side by side and have them act in unison, so that when a user scrolls in one, the other scrolls too, and when the user clicks an item in one, it highlights the same item in the other.

Can I tie the two tables together like this? Is there an easy way to do neatly spaced columns in just one listbox? Is there a better way to do this? I guess sprintf maybe?

Subject: make two listboxes scroll at same time

From: John

Date: 2 Jun, 2009 18:14:02

Message: 3 of 3

Try this -
In the callback routine for listbox1,
sel = get(hObject,'Value');
set(hObject,'listboxtop',sel);
set(handles.listbox2,'Value',sel,'listboxtop',sel);

And in the callback routine for listbox2,
sel = get(hObject,'Value');
set(hObject,'listboxtop',sel);
set(handles.listbox1,'Value',sel,'listboxtop',sel);

You will need to replace listbox1,listbox2 with whatever you assign the 'tag' property for each of these uicontrols.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
listboxtop John 2 Jun, 2009 14:19:03
uicontrol Johnathan 1 Jun, 2009 15:24:04
listbox Johnathan 1 Jun, 2009 15:24:04
sprintf Johnathan 1 Jun, 2009 15:24:03
rssFeed for this Thread

Contact us at files@mathworks.com