Click here to Skip to main content
12,349,379 members (31,657 online)
Click here to Skip to main content

Stats

281.8K views
13.5K downloads
168 bookmarked
Posted

How to skin scrollbars for Panels, in C#

, 13 Jul 2006 CPOL
This article shows you how to create a skinnable scrollbar as a user control, and use it in a Panel to replace the ugly Windows scrollbar.
TestApp
CustomControls
bin
obj
Debug
Refactor
TempPE
Release
CustomControls.dll
Properties
Resources
downarrow.png
ThumbBottom.png
ThumbMiddle.png
ThumbSpanBottom.png
ThumbSpanTop.png
ThumbTop.png
uparrow.png
TestApp
bin
obj
Debug
TempPE
Resource.Designer.cs.dll
Release
Properties
<?xml version="1.0" encoding="utf-8"?>
<root>
  <!-- 
    Microsoft ResX Schema 
    
    Version 2.0
    
    The primary goals of this format is to allow a simple XML format 
    that is mostly human readable. The generation and parsing of the 
    various data types are done through the TypeConverter classes 
    associated with the data types.
    
    Example:
    
    ... ado.net/XML headers & schema ...
    <resheader name="resmimetype">text/microsoft-resx</resheader>
    <resheader name="version">2.0</resheader>
    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
        <value>[base64 mime encoded serialized .NET Framework object]</value>
    </data>
    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
        <comment>This is a comment</comment>
    </data>
                
    There are any number of "resheader" rows that contain simple 
    name/value pairs.
    
    Each data row contains a name, and value. The row also contains a 
    type or mimetype. Type corresponds to a .NET class that support 
    text/value conversion through the TypeConverter architecture. 
    Classes that don't support this are serialized and stored with the 
    mimetype set.
    
    The mimetype is used for serialized objects, and tells the 
    ResXResourceReader how to depersist the object. This is currently not 
    extensible. For a given mimetype the value must be set accordingly:
    
    Note - application/x-microsoft.net.object.binary.base64 is the format 
    that the ResXResourceWriter will generate, however the reader can 
    read any of the formats listed below.
    
    mimetype: application/x-microsoft.net.object.binary.base64
    value   : The object must be serialized with 
            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
    
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with 
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
            : and then encoded with base64 encoding.

    mimetype: application/x-microsoft.net.object.bytearray.base64
    value   : The object must be serialized into a byte array 
            : using a System.ComponentModel.TypeConverter
            : and then encoded with base64 encoding.
    -->
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              </xsd:sequence>
              <xsd:attribute name="name" use="required" type="xsd:string" />
              <xsd:attribute name="type" type="xsd:string" />
              <xsd:attribute name="mimetype" type="xsd:string" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="assembly">
            <xsd:complexType>
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="data">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
              <xsd:attribute ref="xml:space" />
            </xsd:complexType>
          </xsd:element>
          <xsd:element name="resheader">
            <xsd:complexType>
              <xsd:sequence>
                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string" use="required" />
            </xsd:complexType>
          </xsd:element>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <resheader name="version">
    <value>2.0</value>
  </resheader>
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  </resheader>
  <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  <data name="customScrollbar1.DownArrowImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    <value>
        iVBORw0KGgoAAAANSUhEUgAAAA8AAAASCAIAAAAL/BNYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAZdJREFUOE+NUmtS
        wjAYhDvI42S0nEZpGWeEAoeyLbQoOI7eQChFkIrlUZqHm3wI4i8zO9vNZrN9pSikLBbUkBBFkn/HeUlK
        XjKd/0AKiUqV9n3f87wTk8Do+27gubgic0xXDcd3vT7Cmr17F0wIXRcmNqu05AUhWNnoBP1BOAgAiGEQ
        EtQ0CIbhIAz6aJScFfCWpZozfhxFk+lsGoGhgafRGDqevE2m8/HooVK7091SVszuPI4A27p5n8/i2fT1
        5Zmcpn0dxzEEupHU6XpnuVzaeliWBb1YLMhpWvat1cC0arRUGt+ybDrJx+pzlWDNblhg0jRdrZZJkiCD
        5DEdR7N0/QWcQiSUma6jKLpIowz1u812m26oHqApdZeM9rkbLiHb7Q/7DFEwAAfdaZpepLGQZwdidsh5
        zgBoZcLNsosnEYyfwDkXQhDD5DzHFd3g41vClVjVzBhTOdqAFr3jqtY6PzdFtf+r+KcbJp5EdTN8b6OH
        SbneBejokoZZMnv4i3AqtfbxDEqZ4y44BppPQ0/xAwVTBAjxDY29USTfgZn8AAAAAElFTkSuQmCC
</value>
  </data>
  <data name="customScrollbar1.ThumbBottomImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    <value>
        iVBORw0KGgoAAAANSUhEUgAAAA0AAAABCAIAAACKS7NQAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAA9JREFUGFdjNF7G
        zEAEAAAhKADewCYCYAAAAABJRU5ErkJggg==
</value>
  </data>
  <data name="customScrollbar1.ThumbBottomSpanImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    <value>
        iVBORw0KGgoAAAANSUhEUgAAAA0AAAABCAIAAACKS7NQAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACJJREFUGFdjNF7G
        XM2ygoGB4R8QowHGf0z/mRj//2v5GwUAhfwI3vFxkXkAAAAASUVORK5CYII=
</value>
  </data>
  <data name="customScrollbar1.ThumbMiddleImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    <value>
        iVBORw0KGgoAAAANSUhEUgAAAA0AAAAoCAIAAACq6OeuAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAi5JREFUOE+FkNty
        EkEURWP56t/46k/4Ow6Tz/HVcIdhuA3DZQawCJAoM4AQRK5eQX0x6O4+Jz3UJJhdu3btc3pVV1c/ef76
        qf1yf/ZfvXjz7AzcrxP6fScwgtvv90T+lKKOJY0Qc7vdDtuQjpcBh+2D+iHF3PfHxNy3x8Tc1xP6IoVD
        5j5LbbfbUKERYg4EaSOlRlWY26zW8Hq5ogzKer3BsFoxt1wu/0odDgcqR7oNuMVioet6ROq4oJ/rGk75
        vo93ms/nqqPMZrNP8xkKc5in0ylSiUYQN9MPKMxNJpN7z1LPvcUpc+PxWD2LXqneqkde4ZS5kT+Ex8OR
        KtSh0dALOF8KW98fSPue5wnKQx0g+b7BYHD/feIvxW/e+gOPuffX73QtQj6P6DAVsdG16/4Vc2hXvT4y
        VLDs97sB1+v1ut3upRSKUk9MHSTf1+l0Hvw/vO9w+NPtXDLXbrdD36ZpGn6U3ve21Wau5TbbzRYZW9VR
        Wi034Jpuo+m4bsOhpOI4orhOHcn3OY2aU2+EjGOxkUfM1as15ZpdRRdZsykxMlet2GTbqsBUqrYlljKZ
        q5StsK1SxSpZpTIlc+WiGJDKarTKRSyZK+YLcMHMU1EWm4KJZC5vGsqmkcvnTGEoZxbyYmQulzVgECpp
        I2xkjEyWuWw6A2Omcjwa2TRG5jKpdDqZoiSrnkknMTKXSiST8QQyVMQyGUcyl4jFTzoexRFz8WiMHLuI
        qs4ldoEluH/hS19tXA16eAAAAABJRU5ErkJggg==
</value>
  </data>
  <data name="customScrollbar1.ThumbTopImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    <value>
        iVBORw0KGgoAAAANSUhEUgAAAA0AAAABCAIAAACKS7NQAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAA9JREFUGFdjNF7G
        zEAEAAAhKADewCYCYAAAAABJRU5ErkJggg==
</value>
  </data>
  <data name="customScrollbar1.ThumbTopSpanImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    <value>
        iVBORw0KGgoAAAANSUhEUgAAAA0AAAABCAIAAACKS7NQAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAB5JREFUGFdjNF7G
        fCTwCwM2wPif4S/jfyYGZpv1XACFTgbexXTVAgAAAABJRU5ErkJggg==
</value>
  </data>
  <data name="customScrollbar1.UpArrowImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    <value>
        iVBORw0KGgoAAAANSUhEUgAAAA8AAAASCAIAAAAL/BNYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
        YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAZpJREFUOE+NUu1S
        gkAUxeoREn0y0KcpwWkmPx8qPgRLm6beIEVMk2xTEdjtLNdw9Fc7h8u5Z889A7NbEiJTFK4oV3m9UI4r
        bwX6TJQupSyEkgqh6n211lHrPaBc6wDEIZZr/aoulYrWFlxgQEAVGedpBmBxzqnKJZUEDzzoDm6oNICa
        pik55Qwi8olrrYXco5uyz+PzbEyW9fYxe7+Lk3hPNd0nWZIC4FKEGsfya4vsDfshxNsddpuGiQpAYWzN
        GEP20f21iqLP1fZng22zYcANULtaLaMoOnGHwYytvwHyFQNSZOsgCE6+BMGIL3zEqaXsg5sLUal3l8ul
        mS/DMMAXiwUpGLgzGmiregtORbprvXkYAKZx+zGfhbPp2+sLKU3zJgxDEJzowV3WOuOnUTCZzqYBKjjw
        PBqDh5P3yXQ+Hj1WtHt5o3BUqt713IE/8ACQoecTZOt5Q3/gey6yRZbiLDMwx7Jd26FqP1ioBN+yIDqO
        g4sls/GAobdtqVIlguU6lmdbeEt3fgel+z+QbvwpLVyaP3r+LrZ+AQuiUy4Sn/+DAAAAAElFTkSuQmCC
</value>
  </data>
</root>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Greg Ellis
Web Developer www.clubdjpro.com
Canada Canada
I am the co-founder of Cube Software Solutions Inc. and ClubDJ Pro DJ Software.

DJ Software - www.clubdjpro.com
Company Website - Web design edmonton

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160621.1 | Last Updated 13 Jul 2006
Article Copyright 2006 by Greg Ellis
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid