日期:2012-01-30  浏览次数:20529 次

摘自:http://discuss.develop.com/
測試過,挺好的!

  public class ProgressStatusBar : System.Windows.Forms.StatusBar
        {

                public ProgressStatusBar()
                {
                        this.SizingGrip = false;
                        this.ShowPanels = true;
                }
            
                protected override void
OnDrawItem(StatusBarDrawItemEventArgs e)
                {
                        if
(e.Panel.GetType().ToString().EndsWith("ProgressPanel"))
                        {
                                ProgressPanel ProgressPanel =
(ProgressPanel) e.Panel;

                                if (ProgressPanel.Value >
ProgressPanel.Minimum)
                                {
                                        int NewWidth =
(int)(((double)ProgressPanel.Value / (double)ProgressPanel.Maximum) *
(double)ProgressPanel.Width);
                                        Rectangle NewBounds = e.Bounds;
                                        SolidBrush PaintBrush = new
SolidBrush(ProgressPanel.ForeColor);
                                        NewBounds.Width = NewWidth;
    
e.Graphics.FillRegion(PaintBrush, new Region(NewBounds));
                                        PaintBrush.Dispose();