From: ImageAnalyst on 28 Jun 2010 21:51 Yes, of course. Just do something like set(handles.listbox1, 'String', myCellArray); You don't need to assign the return value of set to anything. You do need to load up myCellArray with stuff from your Excel workbook every time your workbook changes to keep your workbook and listbox in sync. A cell array is like a character array except that a character array must be rectangular (like a numerical array) so that all strings must be the same length, while a cell array can contain text strings of different sizes. Think of a cell array like a collection of buckets where you can throw whatever you want into each bucket, be it a string, a matrix, a structure, or whatever.
From: Maxx on 28 Jun 2010 22:00 Thanks guys for your help and time. I may be back with questions, but we shall see! Maxx
From: ImageAnalyst on 28 Jun 2010 22:00 On Jun 28, 9:48 pm, "Maxx " <chats...(a)chemimage.com> wrote: > Thats it man, thanks Matt. Everytime I set the listbox values though (in the code) the callback just skips to the last one. > > set(handle,'string',txt1) > %when I click on this I want it to update to txt2, then txt 3, etc > set(handle,'string',txt2) > %but it skips txt1 and sets the values to txt2 > > How does Matlab reference its callback functions/how does it talk to code within callback? > Maxx ---------------------------------------------------------------------------- You can get the value to find out what items are selected in the listbox. If just one is selected, then you can get the string and set the "value" entry in the string cell array to the new value, and call set to send back the new cell array into the string property. You can then set the value to whatever you want. You may also want to check out listboxtop to scroll it to what you want. Something like this (untested) % Get a list of those indexes that are selected, so we know which items to process. Selected = get(handles.listbox1, 'value'); numberOfSelectedFiles = length(Selected); % Then get list of all of the items in the list, % regardless of whether they are selected or not. ListOfItemNames = get(handles.listbox1, 'string'); % Change the first selected item to 'txt2' ListOfItemNames{Selected(1)} = 'txt2'; % If that doesn't work try () instead of braces {}. % Stuff it back in set(handles.listbox1, 'string', ListOfItemNames); % Select item number 3, just for fun set(handles.listbox1, 'value', 3); % Scroll the listbox so the second item is the top one shown set(handles.listbox1, 'listboxtop', 1);
First
|
Prev
|
Pages: 1 2 Prev: Are MEX files still useful for speed? Next: reading a huge HDF5 file in matlab...takes forever |