Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9069647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:29:03+00:00 2026-06-16T17:29:03+00:00

Pretty much what the title says. Not much else I can add! I’m using

  • 0

Pretty much what the title says. Not much else I can add!

I’m using Windows Form Application.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:29:04+00:00Added an answer on June 16, 2026 at 5:29 pm

    You can pretty much write one simply by inherit Control, a couple of properties and then draw your image using the Paint event of the control.

    I write this example as a basic control. It is attributed with defaults etc., but i wrote it in VB and translated to C# so no guarantee that everything work at first attempt.

    You will still need to implement various error checks and so forth. The control stretches whatever image you define for it. If no image is defined it reverts to a default color.

    Update: Added property to also allow revealing of image.

    Use it for anything; modify as needed (original VB source below for this interested):

    using System.ComponentModel;
    
    [CLSCompliant(true)]
    public class Progressbar : Control {
    
        [CLSCompliant(true)]
        [RefreshProperties(RefreshProperties.Repaint)]
        [Browsable(true)]
        [Category("Appearance")]
        [DefaultValue(100)]
        public int Maximum {
            get {
                return _maximum;
            }
            set {
                _maximum = value;
                this.Invalidate();
            }
        }
    
        [CLSCompliant(true)]
        [RefreshProperties(RefreshProperties.Repaint)]
        [Browsable(true)]
        [Category("Appearance")]
        [DefaultValue(0)]
        public int Value {
            get {
                return _value;
            }
            set {
                _value = value;
                this.Invalidate();
            }
        }
    
        [CLSCompliant(true)]
        [RefreshProperties(RefreshProperties.Repaint)]
        [Browsable(true)]
        [Category("Appearance")]
        [DefaultValue(null.ToString())]
        public Image ProgressbarImage {
            get {
                return _progressbarImage;
            }
            set {
                _progressbarImage = value;
                this.Invalidate();
            }
        }
    
        [CLSCompliant(true)]
        [RefreshProperties(RefreshProperties.Repaint)]
        [Browsable(true)]
        [Category("Appearance")]
        [DefaultValue(typeof(Color), "DarkGray")]
        public Color ProgressbarColor {
            get {
                return _progressbarColor;
            }
            set {
                _progressbarColor = value;
                this.Invalidate();
            }
        }
    
        [CLSCompliant(true)]
        [Browsable(true)]
        [Category("Behavior")]
        [DefaultValue(true)]
        public bool RevealImage {
            get {
                return _revealImage;
            }
            set {
                _revealImage = value;
                this.Invalidate();
            }
        }
    
        private bool _revealImage = true;
        private int _maximum = 100;
        private int _value = 0;
        private Image _progressbarImage = null;
        private Color _progressbarColor = Color.DarkGray;
    
        Progressbar() {
            InitializeComponent();
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
        }
    
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) {
    
            Graphics g = e.Graphics;
            Rectangle r = this.ClientRectangle;
    
            ControlPaint.DrawBorder(g, r, Color.Black, ButtonBorderStyle.Solid);
    
            r.Inflate(-1, -1);
            r.Width = (int.Parse((r.Width 
                            * (_value / _maximum))) - 1);
            if ((r.Width < 1)) {
                return;
            }
    
            if (_progressbarImage == null) {
                Using (Solidbrush b = new SolidBrush(_progressbarColor)) {
                    g.FillRectangle(b, r);
                }
            }
            else {
                g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic;
                if (_revealImage) {
                    g.DrawImage(_progressbarImage, r, r, GraphicsUnit.Pixel);
                }
                else {
                    g.DrawImage(_progressbarImage, r);
                }
            }
        }
    }
    

    Original VB source:

    Imports System.ComponentModel
    
    <CLSCompliant(True)>
    Public Class Progressbar
    
        <CLSCompliant(True),
        RefreshProperties(RefreshProperties.Repaint),
        Browsable(True),
        Category("Appearance"),
        DefaultValue(100)>
        Public Property Maximum As Integer
            Get
                Return _maximum
            End Get
            Set(value As Integer)
                _maximum = value
                Me.Invalidate()
            End Set
        End Property
        <CLSCompliant(True),
        RefreshProperties(RefreshProperties.Repaint),
        Browsable(True),
        Category("Appearance"),
        DefaultValue(0)>
        Public Property Value As Integer
            Get
                Return _value
            End Get
            Set(value As Integer)
                _value = value
                Me.Invalidate()
            End Set
        End Property
        <CLSCompliant(True),
        RefreshProperties(RefreshProperties.Repaint),
        Browsable(True),
        Category("Appearance"),
        DefaultValue(CStr(Nothing))>
        Public Property ProgressbarImage As Image
            Get
                Return _progressbarImage
            End Get
            Set(value As Image)
                _progressbarImage = value
                Me.Invalidate()
            End Set
        End Property
        <CLSCompliant(True),
        RefreshProperties(RefreshProperties.Repaint),
        Browsable(True),
        Category("Appearance"),
        DefaultValue(GetType(Color), "DarkGray")>
        Public Property ProgressbarColor As Color
            Get
                Return _progressbarColor
            End Get
            Set(value As Color)
                _progressbarColor = value
                Me.Invalidate()
            End Set
        End Property
        <CLSCompliant(True),
        Browsable(True),
        Category("Behavior"),
        DefaultValue(True)>
        Public Property RevealImage As Boolean
            Get
                Return _revealImage
            End Get
            Set(value As Boolean)
                _revealImage = value
                Me.Invalidate()
            End Set
        End Property
    
    
        Private _maximum As Integer = 100
        Private _value As Integer = 0
        Private _progressbarImage As Image = Nothing
        Private _progressbarColor As Color = Color.DarkGray
        Private _revealImage As Boolean = True
    
        Sub New()
    
            InitializeComponent()
    
            SetStyle(ControlStyles.AllPaintingInWmPaint, True)
            SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
    
        End Sub
        Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
    
            Dim g As Graphics = e.Graphics
            Dim r As Rectangle = Me.ClientRectangle
    
            ControlPaint.DrawBorder(g, r, Color.Black, ButtonBorderStyle.Solid)
    
            r.Inflate(-1, -1)
            r.Width = CInt(r.Width * _value / _maximum) - 1
            If r.Width < 1 Then Return
    
            If _progressbarImage Is Nothing Then
                Using b As New SolidBrush(_progressbarColor)
                    g.FillRectangle(b, r)
                End Using
            Else
                g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
                If _revealImage Then
                    g.DrawImage(_progressbarImage, r, r, GraphicsUnit.Pixel)
                Else
                    g.DrawImage(_progressbarImage, r)
                End If
            End If
    
        End Sub
    
    End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Pretty much as the title says, using bootcamp. WDDM1.1 compliance and GPU recognition confirmed
My question is pretty much as the title says: How can I get SD
Title pretty much says everything. would like to print (NOT in decimal), but in
Title pretty much says it all... is there an easy way I can simulate
Title pretty much says it i'm looking to add a line to a script
pretty much what the title says. I am using an Ajax Drop Down as
The title pretty much says it all. I'm using a TClientDataset to store an
Pretty much as the title says, if I put an image inside a details
Title pretty much says it all. The web.config, unchanged from how VS2008SP1 generated it,
The title pretty much says it all, but basically I have a main parent

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.