VScrollbar on Panel, always visible

Posted on 2009-02-10
Medium Priority
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
  • 3
  • 2
LVL 19

Expert Comment

ID: 23600061
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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<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

ID: 23600224
sorry we are talking winforms.
LVL 19

Expert Comment

ID: 23600264
Right sorry and the panel is a fixed size right?

Author Comment

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

Accepted Solution

daveamour earned 2000 total points
ID: 23600287
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Loops Section Overview
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

569 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