Progressstatusbar source code (transfer from C #)

Source: Internet
Author: User
status| Source code excerpt: http://discuss.develop.com/
Test, it's good!

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;}
}
}





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.