Results 1 to 10 of 10

Thread: [RESOLVED] Actions of list box

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2010
    Posts
    71

    Resolved [RESOLVED] Actions of list box

    I posted this situation once before and thought I had it taken care of but find I still have the problem.

    I have created a ListBox (lstModels) with properties of:
    Sorted = False
    Columns = 2
    MultiSelect = 0
    Style = 1 - Checkbox

    In the Form Load procedure I enter 16 entries. The first entry is for selecting "All Models." The height of the list box allows 10 entries before spililing over to the next column. When displayed the list box always Appears to have 3 columns always with a horizontal slider shown.

    If I check on any entry in column 1 the check box is checked. If I select the "All models" entry the sub-routine is called that checks all entries. If i clink on the "All models" when that have been previously all been checked all are unchecked. So far, so good.

    If I check ANY entry in column 2 the following happens. The entry does not show that it has been checked, all remaining entries in column 2 no longer show the check boxes (except the one that was clicked on), and the entire list box shifts to the right to display the "3 rd" column (column1 is no longer visible).

    The only procedure in the module that involves the list box is the following.

    Private Sub lstModels_Click()

    Dim N As Integer

    ' if all models was click and all not currently selected then set on all model
    ' in the list
    If lstModels.Selected(0) = True And mCurrAll <> 1 Then
    For N = 1 To lstModels.ListCount - 1
    lstModels.Selected(N) = True
    Next N

    ' set modular flag to indicate that all was previously selected
    mCurrAll = 1

    ' if all models was set to off and all models had been selected then set all
    ' to off
    ElseIf lstModels.Selected(0) = False And mCurrAll = 1 Then
    For N = 1 To lstModels.ListCount - 1
    lstModels.Selected(N) = False
    Next N
    mCurrAll = 0
    End If
    End Sub


    I have tried many many times to adjust the width oif the list box thinging thgat that might be causing the "extra" column but have not been able to make it appear as I think it should "2 columns"

    Any suggestions on what could be causing this would be geratly appreciated.

    Marv

  2. #2
    gibra
    Guest

    Re: Actions of list box

    Set IntegralHeight to False, adjust height and width of listbox.

    The horizontal scroolbar should't appears.

  3. #3

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Actions of list box

    Listboxes in VB6 do not support multi columns. THe Listbox in VB6 and earlier is a single column control.

    Listboxes available in Office development using VBA, however, do support multiple columns. Are you sure you are using VB6 for this project?

  5. #5
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    Re: Actions of list box

    Quote Originally Posted by Hack View Post
    Listboxes in VB6 do not support multi columns. THe Listbox in VB6 and earlier is a single column control.

    Listboxes available in Office development using VBA, however, do support multiple columns. Are you sure you are using VB6 for this project?
    Hmmm, Hack, my VB6 release supports two-column list boxes. It behaves rather goofy, but it does support two columns or more.

    I usually forget that feature and use a non-proportional font and tabs or spaces to show lined-up columns of variables.
    Doctor Ed

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Actions of list box

    Ok, I will admit "does not support" might have been a bit inaccurate. However, funtionally speaking, I would stand by that.

    The Columns property of the listbox enables you to, for lack of a better term, "wiggle" the items in the list, i.e. take your list of items and show them in newspaper like columns. But it is easier to pass a camel through the eye of a needle than it is to actually use the columns as individual data entities. Clearly the VBA teams at Microsoft were not on close speaking terms with the VB teams at Microsoft when it came to building this control.

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jun 2010
    Posts
    71

    Re: Actions of list box

    Quote Originally Posted by gibra View Post
    Set IntegralHeight to False, adjust height and width of listbox.

    The horizontal scroolbar should't appears.
    Thanks for the response. Setting the IntegralHeight to flase did eliminate the extra space to the right of the data displayed. However, it causes another situation to occur. The data in column 2 now overlaps the data in column 1. I haven't been able to determine if there is any means to avoid this. I have adjusted the length of entries but this does not change the column widht. I can't find a property that would determine the widths of the column or determine what does actuallly determine this. Modifing the width of the list box doesn't seem to change anything.

    It has been suggested that I should use a listview instead, but from what I read I don't see how this would do what I am trying to do. The multiple columns is not to display additional data for an entry, it is simply because the height of the list box cannot be greater than the number of entries, so it overflows in newspaper style.

  8. #8

  9. #9
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    Re: Actions of list box

    Quote Originally Posted by Hack View Post
    Ok, I will admit "does not support" might have been a bit inaccurate. However, funtionally speaking, I would stand by that.

    The Columns property of the listbox enables you to, for lack of a better term, "wiggle" the items in the list, i.e. take your list of items and show them in newspaper like columns. But it is easier to pass a camel through the eye of a needle than it is to actually use the columns as individual data entities. Clearly the VBA teams at Microsoft were not on close speaking terms with the VB teams at Microsoft when it came to building this control.
    +1.

    I doubt I could have said it any better than that, and that's precisely why I never released any software with a multi-column list box. My tech support people would have assassinated their boss.
    Doctor Ed

  10. #10

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