开发者

How to create custom ToolStripProgressBar in C# Windows forms?

开发者 https://www.devze.com 2023-04-09 20:18 出处:网络
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..

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 开发者_如何学JAVAcan I set owner draw for this control ?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号