Excel 2007 - ListView Positioning Problem
Using ListView Controls in Excel 2007 VBA UserForms.
For the most part, it works fine. However, when you have ListView controls on different Pages of a Multipage control, the first time you view the page, the ListView control is positioned at the upper left of the container (either the Page, or frame or whatever). If you click onto a different page, then click back to the offending page, the ListView controls are back in their proper position.
I have tried explicitly setting the position properties (Top, Left, etc.) in both the Initialize and Activate events of the Userform, to no avail. Tried refreshing the form and the container. No luck. Have even tried to set the Top and Left positions of the offending ListViews within the Click event of the Multipage control. Still does not work.
I've pretty much given up on using the MSCOMCTL32 controls in my application, but this one was so strange (and consistent), I just thought that someone else must have seen it.
-Mark
Answers
UPDATE: I found a reference to this issue in an on-line excerpt of a book called "Professional Excel Development: The Definitive Guide..." by Rob Bovey, Stephen Bullen, Dennis Wallentin, John Green. It's rather nebulous: "Unfortunately, the MultiPage control is not without its problems, particularly when using non-MSForms controls within a Page." It mentions the ListView and TreeView controls specifically as ones that should not be used on a MultiPage container. Not much to hang your hat on, but at least it is validation that the problem is one of compatibility between the MultiPage control and the others.
THE GOOD NEWS: I found a workaround. Within the Click event of the MultiPage control, I make all the ListViews invisible and then visible again. Works great. The ListViews appear where I position them without any noticeable flicker. Of course, the ultimate solution must be to replace the MultiPage control, possibly with a TabStrip, so that the problem truly goes away. At least until we uncover some stability issues with the TabStrip control......
Hope this helps someone out there, someday.
-Mark- Marked As Answer byTim LiMSFT, ModeratorMonday, November 09, 2009 6:37 AM
All Replies
UPDATE: I found a reference to this issue in an on-line excerpt of a book called "Professional Excel Development: The Definitive Guide..." by Rob Bovey, Stephen Bullen, Dennis Wallentin, John Green. It's rather nebulous: "Unfortunately, the MultiPage control is not without its problems, particularly when using non-MSForms controls within a Page." It mentions the ListView and TreeView controls specifically as ones that should not be used on a MultiPage container. Not much to hang your hat on, but at least it is validation that the problem is one of compatibility between the MultiPage control and the others.
THE GOOD NEWS: I found a workaround. Within the Click event of the MultiPage control, I make all the ListViews invisible and then visible again. Works great. The ListViews appear where I position them without any noticeable flicker. Of course, the ultimate solution must be to replace the MultiPage control, possibly with a TabStrip, so that the problem truly goes away. At least until we uncover some stability issues with the TabStrip control......
Hope this helps someone out there, someday.
-Mark- Marked As Answer byTim LiMSFT, ModeratorMonday, November 09, 2009 6:37 AM

