+ Reply to Thread
Results 1 to 12 of 12

Can one use a Listbox on UserForm without allowing the user to select an item?

  1. #1
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Can one use a Listbox on UserForm without allowing the user to select an item?

    Is there a property which one can set on a listbox (on a userform) which would allow one to display items without allowing the user to select one of the items?

    Steven Craig Miller
    Last edited by StevenM; 03-26-2012 at 03:31 PM.

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Can one use a Listbox on UserForm without allowing the user to select an item?

    My first thought is to just have nothing happen in your code when the listbox is being viewed and a value is selected. You can leave the a list box filled but without programmatic meaning. Just create the list box, fill it, and leave it. Is this what you mean?
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Can one use a Listbox on UserForm without allowing the user to select an item?

    Actually, I was aiming more for the look and feel of a label but with a side scroll-bar. The problem with just leaving "the list box filled but without programmatic meaning" is that the user can still click on items and the item appears selected. I would like to find a way to prohibit the selection of items in the list (if possible).

    Steven Craig Miller

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Can one use a Listbox on UserForm without allowing the user to select an item?

    Hi StevenM
    In the ListBox Properties play with the Enabled and the Locked Properties until you get the effect you want.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  5. #5
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Can one use a Listbox on UserForm without allowing the user to select an item?

    I've (now) tried changing:

    Please Login or Register  to view this content.
    But changing these values (away from the above) also locked the vertical-scrolling scroll-bar on the side so that there was no way to view the other items on the list.

    Steven Craig Miller

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Can one use a Listbox on UserForm without allowing the user to select an item?

    Hi Steven
    Not sure what you're trying to do but try this (change the ListBox name as appropriate)
    Please Login or Register  to view this content.

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Can one use a Listbox on UserForm without allowing the user to select an item?

    Instead of listing the items in a list box, you could put a linefeed delimited string in a TextBox with Multiline = True, Locked=True and ScrollBars = fmScrollBarsVertical
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  8. #8
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Can one use a Listbox on UserForm without allowing the user to select an item?

    MikeRickson wrote:
    Instead of listing the items in a list box, you could put a linefeed delimited string in a TextBox with Multiline = True, Locked=True and ScrollBars = fmScrollBarsVertical
    That is almost what I'm wanting. There are two problems.

    (1) The vertical scroll bars are not activated until the textbox is clicked. Is there any way to activate them when initializing the userform?

    (2) There is a vertical insertion point bar inside the text. The "Locked=True" keeps the user from editing the text. But is there a way to get rid of the insertion point bar too?

    Thanks for your help!

    Steven Craig Miller

  9. #9
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Can one use a Listbox on UserForm without allowing the user to select an item?

    Try code like this
    Please Login or Register  to view this content.
    Note that some of the properties specified in the Intialize event could be set at design time rather than in the I. event. Others cannot.
    The way to get the scroll bar to appear is to set the focus to the tbxDisplay and then to someOtherControl.

    The selection icon cannot be removed. This code puts it out of the way (at the start of the text) but leaves it there. As I was fiddling, I discovered that (as a potential user) the ability to highlight, by selection, part of the contents of the Text Box was a good thing. If your users would feel differently, then KeyDown or MouseUp events could be added to keep the focus away from the text box.

  10. #10
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Can one use a Listbox on UserForm without allowing the user to select an item?

    To: mikerickson,

    Thanks for your help! It is greatly appreciated!

    Per your suggestion, I added:
    Please Login or Register  to view this content.
    It is not perfect. I would have been nice if the selection icon could be removed. But all and all, I think I will use this method. Thanks for your help.

    Steven Craig Miller

  11. #11
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Can one use a Listbox on UserForm without allowing the user to select an item?

    Perhaps

    Please Login or Register  to view this content.

  12. #12
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Can one use a Listbox on UserForm without allowing the user to select an item?

    Thanks! That is even better!

    Steven Craig Miller

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1