Results 1 to 5 of 5

Thread: [RESOLVED] [2008] ListBox DrawItem Horizontal scrollbar

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    Manchester, England
    Posts
    255

    Resolved [RESOLVED] [2008] ListBox DrawItem Horizontal scrollbar

    Hi,
    As the title suggests, I'm using VB.NET 2008, and I've got a problem with a disappearing horizontal scrollbar on a ListBox where I'm using the DrawItem event. DrawItem is set to OwnerDrawFixed.
    I think I know WHY I'm not seeing the scrollbar, but I can't figure out how to fix it. I may have to use a DataGridView, but I'd prefer to understand the solution to the ListBox problem.
    What I think is happening is this line is filling my rectangle with my brush to the boundary of the rectangle:
    Code:
    e.Graphics.FillRectangle(myBrush, e.Bounds)
    The line is filling the rectangle with my data:
    Code:
    e.Graphics.DrawString(Me.lstReportContent.Items(e.Index), e.Font, myBrush, New RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height))
    I've seen that I can reduce e.Bounds.Width, and each line is cut short. Naturally, I'd have thought that if I increase e.Bounds.Width, the item line would be longer than the visible rectangle width.
    At home - VB.NET 2005/2008 Express, Visual Web Developer 2005 Express
    At work - VS 2008 Standard (VB)
    .NET 2.0/3.5


    Visual Studio Express Learning Centre | How do I videos | MSDN VB Express Forum | MSDN VB Developer Centre

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2008] ListBox DrawItem Horizontal scrollbar

    You need to set the HorizontalExtent property of the control to trigger the drawing of the scroll bar, which I discovered from the second result returned by a Google search for listbox ownerdraw scrollbar.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    Manchester, England
    Posts
    255

    Re: [2008] ListBox DrawItem Horizontal scrollbar

    Thanks.
    Was listbox ownerdraw scrollbar the first thing you searched for?
    At home - VB.NET 2005/2008 Express, Visual Web Developer 2005 Express
    At work - VS 2008 Standard (VB)
    .NET 2.0/3.5


    Visual Studio Express Learning Centre | How do I videos | MSDN VB Express Forum | MSDN VB Developer Centre

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2008] ListBox DrawItem Horizontal scrollbar

    Quote Originally Posted by penguin5000
    Thanks.
    Was listbox ownerdraw scrollbar the first thing you searched for?
    As a matter of fact it was. It seemed the logical choice as you were looking for information about a scrollbar in a listbox that was owner-drawn.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Location
    Manchester, England
    Posts
    255

    Re: [RESOLVED] [2008] ListBox DrawItem Horizontal scrollbar

    I guess its all about what you search for.
    The search technique that I failed with was pretty much as per my title, i.e. different combinations of ListBox DrawItem Horizontal scrollbar. There were lots of occurrences of the problem, but no real solution.
    Anyway, problem solved. Thanks again.
    At home - VB.NET 2005/2008 Express, Visual Web Developer 2005 Express
    At work - VS 2008 Standard (VB)
    .NET 2.0/3.5


    Visual Studio Express Learning Centre | How do I videos | MSDN VB Express Forum | MSDN VB Developer Centre

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