Listbox control selection getting corrupted

R

Rick Lowe

I'm working on a user form for Excel, which reads several headings from the
first row of a worksheet and then displays them in a multi-select listbox. As
I add the items to the listbox, I also set the "selected" member to TRUE if
the label appears in a visible column and FALSE if the column is hidden. All
of this works almost all of the time. The code to do this is in the form's
Initialize event.

I am looking at one test case where a couple of items that should be
selected are not selected. The problem disappears if I use the debugger, and
it also disappears if I raise a message box anywhere in the form's Initialize
event handler.

I added some code to to both the form Activate and Initialize events to
raise a message box if the form's "selected" property doesn't look right.
Neither message box appears, so I assume that the "selected" property is
getting corrupted somewhere between the Activate event and the time the form
is actually drawn on the screen.

Any advice? I'm using Excel 2003 SP1 on Windows XP Pro SP1.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top