user186246
user186246

Reputation: 1877

How to create custom ToolStripProgressBar in C# Windows forms?

How to create custom ToolStripProgressBar in C# Windows forms?

I want to create a progressbar with the style as continuos but in windows xp it is not possible..

So how can I set owner draw for this control ?

Upvotes: 1

Views: 2484

Answers (1)

hrh
hrh

Reputation: 658

I can give you more Information on the ToolStripControlHost, I created a ProgressBar using this with the following code

public class ToolStripProgressBarC : ToolStripControlHost
{
    // Call the base constructor passing in a ProgressBar instance.
    public ToolStripProgressBarC() : base(new ProgressBar()) 
    {
        ((ProgressBar)Control).Style = ProgressBarStyle.Continuous;
    }

    public ProgressBar ProgressBarControl
    {
        get
        {
            return Control as ProgressBar;
        }
    }

    // Expose the ProgressBar.Value as a property.
    public int Value
    {
        get
        {
            return ProgressBarControl.Value;
        }
        set { ProgressBarControl.Value = value; }
    }

}

I then added it to my tool strip like so.

ToolStripProgressBarC tsp = new ToolStripProgressBarC();
tsp.Value = 90;
toolStrip1.Items.Add(tsp);

You should be able to do any extra overriding that you want by adding extra functions to the "ToolStripProgressBarC" class.

Upvotes: 1

Related Questions