Results 1 to 17 of 17

Thread: [RESOLVED] Scrollbar not appearing on panel

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    South Charleston, WV, USA
    Posts
    607

    Resolved [RESOLVED] Scrollbar not appearing on panel

    I’m trying to display a large list of data with a panel with dynamic textboxes but there is no scrollbar appearing on the panel. The autoscroll property of the panel is set to True in the designer. The initial size of the panel is 960, 620 and the size of the form is 1000, 800.
    Code:
    100 + (NumRows * iRowHeight)
    calculates as 65,535. Can someone tell how to get the scrollbar to appear? Or is a panel the wrong way to go? I do not want a datagridview or listview.

    Code:
            iRowHeight = 36
            NumRows = dt.Rows.Count
            ReportPanel.Height = 100 + (NumRows * iRowHeight)
            Dim txtbx() As TextBox
            txtbx = Nothing
            ReDim txtbx(NumRows)
            index1 = 1
            For Each row As DataRow In dt.Rows
                txtbx(index1) = New TextBox
                txtbx(index1).Visible = True
                txtbx(index1).Top = 5 + (iRowHeight * index1)
                txtbx(index1).Width = 225
                txtbx(index1).Height = 20
                txtbx(index1).Left = 140
                txtbx(index1).Text = IIf(IsDBNull(row.Item("warehouse")), String.Empty, row.Item("warehouse"))
                AddHandler txtbx(index1).Click, AddressOf MyMessage
                Me.ReportPanel.Controls.Add(txtbx(index1))
                index1 = index1 + 1
            Next

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: Scrollbar not appearing on panel

    You ought to look at the FlowLayoutPanel, as that would likely be a better way to go with dynamic controls.
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    South Charleston, WV, USA
    Posts
    607

    Re: Scrollbar not appearing on panel

    Thanks.

    I tried this and I'm getting some puzzling results. Using the above code except adding the textbox to a flowlayout panel it scrolls the textboxes out across the panel. (Or maybe down and then across.) And no scroll bar appears. Autoscroll is set to true in the designer. So I made the panel narrower so as to be wide enough for just 1 textbox and when this thing is being created the whole screen blacks out for a few seconds whenever I move the cursor. When it stopped there was only 1 textbox per row and a scrollbar but the scrollbar didn't work.

    (The final result is to have many columns.)

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: Scrollbar not appearing on panel

    In your original code, you're increasing the size of the panel to fit all of your textboxes. Therefore there are never any controls outside of the panels visible viewport. Try your original code and set the form's autoscroll property to true...

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    South Charleston, WV, USA
    Posts
    607

    Re: Scrollbar not appearing on panel

    Okay, it's much better after removing the height-setting statement. But how do I add more textboxes going across? I tried creating another one in code, increasing the .Left amount and that didn't work.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    South Charleston, WV, USA
    Posts
    607

    Re: Scrollbar not appearing on panel

    Forgot the .Add statement. Thanks!

  7. #7
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: Scrollbar not appearing on panel

    The flowlayout panel was largely designed for this, and it has lots of different properties. There is one that adds horizontally vs vertically, and it sounds like you had that set. Of course, there's nothing particularly special about the flowlayout panel. It's doing what you are doing, so if you get it working without the flowlayout panel then there may be no real advantage.
    My usual boring signature: Nothing

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    South Charleston, WV, USA
    Posts
    607

    Re: Scrollbar not appearing on panel

    How would I get it to work without the flowlayout panel? With a regular panel?

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    South Charleston, WV, USA
    Posts
    607

    Re: Scrollbar not appearing on panel

    How do you get a scroll bar to appear on a regular panel?

  10. #10
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: Scrollbar not appearing on panel

    I told you how...
    I thought you had it working???

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    South Charleston, WV, USA
    Posts
    607

    Re: Scrollbar not appearing on panel

    I never got a scrollbar on the panel. The flowlayout panel has a scrollbar but the textboxes wrap around/don't jump to the next line. Obviously I need to fill out the width with the rest of the text boxes but I have misgivings that I will get it to look the way I want. Also, I think the flowlayout panel is executing slower than the panel. So for that reason alone I would want to go with the panel.

  12. #12
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: Scrollbar not appearing on panel

    With autoscroll on, the panel will show scrollbars when there are controls positioned outside of the visible bounds of the panel.
    For example:

    Panel1 size = 200, 100
    Textbox1 location = 20,150

    Textbox1 is beyond the bottom of Panel1, so a vertical scrollbar will appear...

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    South Charleston, WV, USA
    Posts
    607

    Re: Scrollbar not appearing on panel

    All right I will give this a try.

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    South Charleston, WV, USA
    Posts
    607

    Re: Scrollbar not appearing on panel

    This looks good! The problem was in setting the height of the panel to be the size of the full list instead of the visible size same as with the flowlayout panel.

    And panel executes faster than flowlayoutpanel.

    So it looks like I'm good for now. Knock on wood. Thanks both of you.

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    South Charleston, WV, USA
    Posts
    607

    Re: Scrollbar not appearing on panel

    You can mark this as resolved.

  16. #16
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: Scrollbar not appearing on panel

    The panel is also easier for positioning controls

  17. #17
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: Scrollbar not appearing on panel

    See the menu at the top right of your original post - Thread Tools. It has an option to Mark Thread Resolved

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