VScrollbar on Panel, always visible

Posted on 2009-02-10
Last Modified: 2012-05-06

I have a application where i need a Panel to always show its Scrollbar even though it is currently not overflown.
The thing is that the size of the panels residing within the panel has to be the same at all times, because i have a fixed header which size is constant

An example of the issue.

The scrollbar makes it out of sync.

Any ideas are welcome
Question by:mSchmidt
    LVL 19

    Expert Comment

    The attached code works for me.
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="PanelScrollBar.aspx.cs" Inherits="PanelScrollBar" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <html xmlns="">
    <head runat="server">
        <form id="form1" runat="server">
            <asp:Panel runat="server" ID="MyPanel" Width="400" Height="300" ScrollBars="Vertical" BorderColor="Beige" BorderStyle="Solid">
                <p>This is some text</p>
                <p>This is some text</p>
                <p>This is some text</p>

    Open in new window


    Author Comment

    sorry we are talking winforms.
    LVL 19

    Expert Comment

    Right sorry and the panel is a fixed size right?

    Author Comment

    correct, when adding additional elements, currently the scrollbar will pop up at some point.
    LVL 19

    Accepted Solution

    Bit of a hack but add something just large enough to make the scrollbar always be there but hide it by making the colour so that it belnds in - don't actually set it's Visible property to false but just make it blend into the background.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now