摘自: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();
}
else
{
base.ondrawitem(e);
}
}
else
{
base.ondrawitem(e);
}
}
public void updatevalue(progresspanel progresspanel, int
newvalue)
{
progresspanel.value = newvalue;
}
}
public class progresspanel : system.windows.forms.statusbarpanel
{
private int m_minimum = 1;
private int m_maximum = 100;
private int m_value = 0;
private color m_color;
public progresspanel()
{
this.style = statusbarpanelstyle.ownerdraw;
this.forecolor = color.darkblue;
}
public int minimum
{
get { return m_minimum; }
set { m_minimum = value; }
}
public int maximum
{
get { return m_maximum; }
set { m_maximum = value; }
}
public int value
{
get { return m_value; }
set { m_value = value; }
}
public color forecolor
{
get { return m_color; }
set { m_color = value; }
}
}
新闻热点
疑难解答