Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
ListBox Questions
I have an unbound ListBox on a VBA form with enough items that vertical
scrolling is required to see all of the items and have a couple of questions: Q1: I populate the ListBox in my VBA code and select one of the entries. Is there a way to ensure that the selected item is scrolled into the visible portion of the ListBox? For example if the ListBox has 50 items, can display 20 at a time and my code has selected item 30, is there a way to force the display of items 20 - 40? Q2: After I populate the ListBox, I'd like to allow the user to scroll through the ListBox but not change the selected item. I've played around with various combinations of the Enabled and Locked properties and it seems like if I disable or lock the control, then scrolling is disabled along with selection. TIA, josh |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
ListBox Questions
Sorry, I just figured out the answer to Q1 ... TopIndex ... duh.
Still interested in help on Q2. josh "Josh Sale" <jsale@tril dot cod wrote in message ... I have an unbound ListBox on a VBA form with enough items that vertical scrolling is required to see all of the items and have a couple of questions: Q1: I populate the ListBox in my VBA code and select one of the entries. Is there a way to ensure that the selected item is scrolled into the visible portion of the ListBox? For example if the ListBox has 50 items, can display 20 at a time and my code has selected item 30, is there a way to force the display of items 20 - 40? Q2: After I populate the ListBox, I'd like to allow the user to scroll through the ListBox but not change the selected item. I've played around with various combinations of the Enabled and Locked properties and it seems like if I disable or lock the control, then scrolling is disabled along with selection. TIA, josh |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
ListBox Questions
Josh Sale wrote:
Q2: After I populate the ListBox, I'd like to allow the user to scroll through the ListBox but not change the selected item. I've played around with various combinations of the Enabled and Locked properties and it seems like if I disable or lock the control, then scrolling is disabled along with selection. save listbox.selected list and restore it when user try to change selection. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
ListBox Questions
Kris,
Thanks for the suggestion, but it doesn't seem to work! If I create a lstBox_Change event handler, it does indeed get control when the user clicks around in the ListBox. However, there appears to be something that prevents selection change from working from within that event handler. For example if I execute lstBox.Selected(4) = False from within that event handler, the 4th item remains selected. Based on your suggestion, I tried doing something similar using the lstBox_AfterUpdate event. When I place my code in that event handler I am able to alter the selected item(s) in the ListBox. This seemed like the ticket except that under certain conditions, it appears that a whole bunch of these events can get queued up and then my code goes into a long loop processing those events. If I break the code while its in that loop and look at the call stack, there is nothing obvious calling the routine (the only entry is the frm.Show line executed way earlier). I also tried using lstBox_BeforeUpdate. I thought that by setting the Cancel argument to True, I could prevent the change in selection but that didn't work either. lstBox_Click is never raised by the types of clicking around in the ListBox that I'm doing. So bottom line is, I'm still stuck! josh "Kris" wrote in message ... Josh Sale wrote: Q2: After I populate the ListBox, I'd like to allow the user to scroll through the ListBox but not change the selected item. I've played around with various combinations of the Enabled and Locked properties and it seems like if I disable or lock the control, then scrolling is disabled along with selection. save listbox.selected list and restore it when user try to change selection. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Answers to questions posing more questions in a workbook | Excel Worksheet Functions | |||
View Questions and Answer to questions I created | Excel Discussion (Misc queries) | |||
Listbox questions | Excel Programming | |||
listbox.value not equal to listbox.list(listbox.listindex,0) | Excel Programming | |||
Listbox and Array questions | Excel Programming |