CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Nov 2018
    Posts
    9

    want 2 columns but getting 3

    Hi, I would use a flexgrid but VB6 (enterprise) says it's not registered (even though it's there in the list, with its check box ticked) so I have used a list box (simple dropdown list) instead, which is perfectly adequate, apart from...
    At design time I set the number of columns at 2.
    At runtime however I currently get 3 columns - with a horizontal scrollbar added. I think that scroller may be the problem, but I cant see how to get rid of it, since there's no reference to it in the properties window. The list is simple and static, and I load it in form_load as follows (all items follow this model, all have 3 letters. They are constellation abbreviations):
    Code:
    With ddConstells
    .Width = 1935
    .AddItem "And"
    .AddItem "Aqr"
    .AddItem "Aql"
    .AddItem "Ari"
    .AddItem "Aur"
    .AddItem "Boo"
    .AddItem "Cam"
    .AddItem "Cnc"
    End With
    Anyone come to the aid of this damnfool in distress? ;-)

  2. #2
    Join Date
    Aug 2023
    Posts
    3

    Re: want 2 columns but getting 3

    The problem is that you are setting the width of the listbox to 1935 pixels. This is wider than the width of two columns, so a third column is added to accommodate the extra text. To fix this, you can either reduce the width of the listbox or set the MultiColumn property to False. Have a look here
    Last edited by smylit45; September 29th, 2023 at 06:45 AM.

  3. #3
    Join Date
    Nov 2018
    Posts
    9

    Re: want 2 columns but getting 3

    Quote Originally Posted by smylit45 View Post
    The problem is that you are setting the width of the listbox to 1935 pixels. This is wider than the width of two columns, so a third column is added to accommodate the extra text. To fix this, you can either reduce the width of the listbox or set the MultiColumn property to False.
    Okay... I removed the '1' from the width, so that made the new width 935 (I thought the number here was in twips, not pixels. Clearly 1935 pixels is enormous for a dropdown box!) It obviously was twips, because this time the width is about half what it was - but I still get three columns and a horizontal scrollbar.

    I don't want to set the multicolumn to false because I want a multi column box. (well, 2 columns anyway)

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,369

    Re: want 2 columns but getting 3

    It is not clear whether you mean a ListBox or ListCtrl.
    Also some code snippets would help to understand your problem.
    Victor Nijegorodov

  5. #5
    Join Date
    Nov 2018
    Posts
    9

    Re: want 2 columns but getting 3

    Quote Originally Posted by VictorN View Post
    It is not clear whether you mean a ListBox or ListCtrl.
    Also some code snippets would help to understand your problem.
    Thanks Victor,dd
    It's a simple listbox (dropdown box) called ddConstells - actually the only code is what I originally posted. The problem seems to be what VB does with it.
    In the properties window at design time I set its columns to 2. But at run time I get (so far) 3 columns plus a horizontal scrollbar! That scrollbar seems to be there purely because there are now 3 columns. I do however want a vertical scrollbar but that isn't there! So... where do those scrollbars come from, and how can I control them?

  6. #6
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,802

    Re: want 2 columns but getting 3

    [@babystarman - you might get further help on this site's sister site https://www.vbforums.com/forumdispla...-6-and-Earlier which is more active]
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  7. #7
    Join Date
    Nov 2018
    Posts
    9

    Re: want 2 columns but getting 3

    Quote Originally Posted by 2kaud View Post
    [@babystarman - you might get further help on this site's sister site https://www.vbforums.com/forumdispla...-6-and-Earlier which is more active]
    Many thanks - I shall give that a try!

  8. #8
    Join Date
    Aug 2023
    Posts
    3

    Re: want 2 columns but getting 3

    Have you found a solution?

  9. #9
    Join Date
    Nov 2018
    Posts
    9

    Re: want 2 columns but getting 3

    Quote Originally Posted by smylit45 View Post
    Have you found a solution?
    Nope! But actually I have had an idea, to rewrite the code on my laptop, where everything is working as it should! So, end of problem.

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

Featured