Results 1 to 9 of 9

Thread: Listbox problem.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2014
    Posts
    23

    Exclamation Listbox problem.

    Hello,

    I have in listbox1 five names.

    I want to by click on one name show on same place instead of listbox1 listbox2, with other names.

    Code:
    Select Case ListBox1.SelectedIndex
                Case 0
                (what to do there, if i want to display listbox2 on same place)
    End Select
    Thank you.

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Listbox problem.

    Can't understand the question

    If you are talking about positioning the listbox then the top and left properties are the key

  3. #3
    Hyperactive Member
    Join Date
    Jun 2014
    Location
    Lahore, Pakistan
    Posts
    450

    Re: Listbox problem.

    Do you want to move of the index of listbox2 as same as the listbox1 when you choose item from listbox1 ?

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jul 2014
    Posts
    23

    Re: Listbox problem.

    Essentially I need to create another Layer in program. I need to end listbox1 and instead of it get listbox2

  5. #5
    New Member
    Join Date
    Jul 2014
    Location
    Germany
    Posts
    8

    Re: Listbox problem.

    Hi,

    in my understanding, you want to show another Listbox when clicking on an entry in Listbox 1, right?

    the trick is to create 2 listboxes and set lisbox2 invisible. also, it may help to use .left and .top property to move the listbox 2 to the position of listbox 1. this can be done when initializing the userform depending on what you are trying to achieve.

    try sth like this (must be adopted to your needs)

    Code:
    Private Sub UserForm_Initialize()
        'assuming listbox 1 has position .left = 10 and .top = 20
        listbox2.Visible = False
        listbox2.Left = 10
        listbox2.Top = 20
    End Sub
    
    'and your code snippet should look like this
    Select Case ListBox1.SelectedIndex
                Case 0
                    listbox1.visible = false
                    listbox2.visible = true
    End Select
    I guess your code snippet should be located in a mouse event. Doing this, listbox1 disappears when clicking on an entry and listbox2 shows up.


    --------------------------------------------------------------------
    Center of Efficiency UG (haftungsbeschränkt)
    www.centerofefficiency.com

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Listbox problem.

    Quote Originally Posted by madmancz View Post
    Essentially I need to create another Layer in program. I need to end listbox1 and instead of it get listbox2
    You really need to do a better job of wording your questions.
    I still have no idea what you are trying to ask.
    Layer in program? End list1? get list2?

  7. #7
    Hyperactive Member
    Join Date
    Jun 2014
    Location
    Lahore, Pakistan
    Posts
    450

    Re: Listbox problem.

    Quote Originally Posted by DataMiser View Post
    You really need to do a better job of wording your questions.
    I still have no idea what you are trying to ask.
    Layer in program? End list1? get list2?
    Is he talking about to layer garlic paste on fried chicken with some lemons ?

  8. #8
    Hyperactive Member
    Join Date
    Oct 2013
    Posts
    389

    Re: Listbox problem.

    a Wild guess here, I believe he's trying to input a large amount of entries into a listbox and since it only supports up to a certain number of entries, he wants to display a second listbox, and place the remaining entries in it, and then make it visible only when the user scrolls down to the value of List1 (which in turn, will then go invisible).

    If that indeed is the case, you can use other tools, don't get stuck with listbox.
    either that, or simply have String that contain all the entries, and load into the listbox,
    only half of them at a time, (have a button to load them by sections, like Page 1, Page 2, ...)

  9. #9
    New Member
    Join Date
    Jul 2014
    Location
    Germany
    Posts
    8

    Re: Listbox problem.

    ;DDD

    I think he wants to do the following:

    1. show listbox1 with some entries
    2. when user clicks on an entry in listbox1 -> show another listbox2 instead of listbox1, thus, same size and position, but different content

    example: listbox1 with first and sur name -> click on a name -> show listbox2 with addresses of name


    depending on your data structure the best way might be to "refill" listbox 1, thus delete all entries when an entry was selected and then fill listbox1 with your new entries.
    by doing so, you wouldn't need listbox2 at all

Posting Permissions

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



Click Here to Expand Forum to Full Width