From: James Roberts on 19 Mar 2010 11:38 I am having some trouble linking two list boxes in a matlab GUI i am generating My two list boxes are each displaying a set of values that correspond the the x and y values of my dataset. I would like to set up my GUI so that when the user uses the scrollbar to go through one list the other list will scroll down as well. Currently I'm having trouble doing this. I've tried using LINKPROP but i feel like i'm somehow not using it properly - the help page says that the link object must remain referenced but I don't know how/where to reference it for when the user clicks on the scrollbar. Thanks for any help!
From: Steven Lord on 19 Mar 2010 13:09 "James Roberts" <jamesc_roberts(a)hotmail.com> wrote in message news:ho05os$kj2$1(a)fred.mathworks.com... >I am having some trouble linking two list boxes in a matlab GUI i am >generating > > My two list boxes are each displaying a set of values that correspond the > the x and y values of my dataset. I would like to set up my GUI so that > when the user uses the scrollbar to go through one list the other list > will scroll down as well. > > Currently I'm having trouble doing this. I've tried using LINKPROP but i > feel like i'm somehow not using it properly - the help page says that the > link object must remain referenced but I don't know how/where to reference > it for when the user clicks on the scrollbar. Use LINKPROP to link the two listboxes' ListboxTop properties, then store the object returned from LINKPROP somewhere that it won't go out of scope (be deleted) when the callback where you link the properties exits. One example of such a location is the UserData property for one of the linked listboxes. Then delete that object when you want to end the linking behavior. See the Examples section of the reference page for LINKPROP for an example that uses SETAPPDATA instead of the UserData property of the listboxes. http://www.mathworks.com/access/helpdesk/help/techdoc/ref/linkprop.html -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
From: us on 19 Mar 2010 13:28 "James Roberts" <jamesc_roberts(a)hotmail.com> wrote in message <ho05os$kj2$1(a)fred.mathworks.com>... > I am having some trouble linking two list boxes in a matlab GUI i am generating > > My two list boxes are each displaying a set of values that correspond the the x and y values of my dataset. I would like to set up my GUI so that when the user uses the scrollbar to go through one list the other list will scroll down as well. > > Currently I'm having trouble doing this. I've tried using LINKPROP but i feel like i'm somehow not using it properly - the help page says that the link object must remain referenced but I don't know how/where to reference it for when the user clicks on the scrollbar. > > Thanks for any help! unfortunately, the listbox's scrollbar is not accessible in the current prop list... you could link the values... uh=uicontrol('position',[10,10,100,200],... 'style','listbox',... 'string',num2cell(1:50)); vh=uicontrol('position',[110,10,100,200],... 'style','listbox',... 'string',num2cell(1:50)); lh=linkprop([uh;vh],{'value'}); % now, click on various VALUEs in either box... for more on scrollbars, see also http://undocumentedmatlab.com/blog/customizing-listbox-editbox-scrollbars us
From: ImageAnalyst on 19 Mar 2010 13:34 Why not use a table control instead of two listbox controls? Otherwise, have you tried setting the ListboxTop property of the other listbox? Like in the listbox1 callback, do something like this (untested) % Find out which index is at the top of listbox 1. lb1Top = get(handles.listbox1, 'ListboxTop'); % Assign that same index to be at the top of listbox2. % Should work as long as both listboxes have the same number of items in them. set(handles.listbox2, 'ListboxTop', lb1Top); This is probably pretty similar to what linkprop does.
|
Pages: 1 Prev: Define a segmented pipeline block in simscape ? Next: repmat elements of cell array |