protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.Style |= 0x04;
return cp;
}
}

上面是垂直方向,从下到上

下面是美观

 public class VerticalProgressBar : ProgressBar
{
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.Style |= 0x04;
return cp;
}
} public VerticalProgressBar()
{
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
}
/// <summary>
/// 从下到上
/// </summary>
/// <param name="e"></param>
protected override void OnPaint(PaintEventArgs e)
{
SolidBrush brush = null; Rectangle rec = new Rectangle(, , this.Width-, this.Height-); if (ProgressBarRenderer.IsSupported)
{
ProgressBarRenderer.DrawHorizontalBar(e.Graphics, rec);
}
//Pen pen = new Pen(this.ForeColor, 1); //左上的线色
Pen pen = new Pen(Color.Red, );
e.Graphics.DrawRectangle(pen, rec);
//绘制进度条空白处
e.Graphics.FillRectangle(new SolidBrush(this.BackColor), , , rec.Width - , rec.Height - ); rec.Width -= ;
rec.Height = (int)(rec.Height * ((double)Value / Maximum)) - ;
brush = new SolidBrush(this.ForeColor);
//绘制进度条进度
e.Graphics.FillRectangle(brush, , Height - rec.Height - , rec.Width, rec.Height);
}
/// <summary>
/// 从左到右
/// </summary>
/// <param name = "e" ></ param >
//protected override void OnPaint(PaintEventArgs e)
//{
// SolidBrush brush = null;
// Rectangle rec = new Rectangle(0, 0, this.Width - 1, this.Height - 1); // if (ProgressBarRenderer.IsSupported)
// {
// ProgressBarRenderer.DrawHorizontalBar(e.Graphics, rec);
// }
// //Pen pen = new Pen(this.ForeColor, 1); //左上的线色
// Pen pen = new Pen(Color.Red, 1);
// e.Graphics.DrawRectangle(pen, rec);
// e.Graphics.FillRectangle(new SolidBrush(this.BackColor), 1, 1, rec.Width - 1, rec.Height - 1); // rec.Height -= 1;
// rec.Width = (int)(rec.Width * ((double)Value / Maximum)) - 1;
// brush = new SolidBrush(this.ForeColor);
// e.Graphics.FillRectangle(brush, 1, 1, rec.Width, rec.Height);
//}
}
 
声明:原创博客请在转载时保留原文链接或者在文章开头加上本人博客地址,如发现错误,欢迎批评指正。凡是转载于本人的文章,不能设置打赏功能,如有特殊需求请与本人联系!

c# ProgressBar进度条方向和美观的更多相关文章

  1. Qt Quick 常用元素:ComboBox(下拉列表) 与 ProgressBar(进度条)

    一.ComboBox ComboBox,即下拉列表框,由一个列表框和一个标签控件(或编辑控件)组成.ComboBox 的下拉列表是使用 Menu 实现的,列表内的每个条目对应一个 Menultem. ...

  2. Android学习笔记- ProgressBar(进度条)

    本节引言: 本节给大家带来的是Android基本UI控件中的ProgressBar(进度条),ProgressBar的应用场景很多,比如 用户登录时,后台在发请求,以及等待服务器返回信息,这个时候会用 ...

  3. progressbar进度条组件

    Progressbar 进度条组件 通过$.fn.progressbar.fn.defaults重写默认的defaults进度条(progressbar)提供了一种显示长时间操作进度的反馈.进度可被更 ...

  4. ProgressBar(进度条)、SeekBar(拖动条)与星级评分条(RatingBar)

    1.ProgressBar(进度条) (1)介绍 (2)常用属性 (3)xml代码 <ProgressBar android:id="@+id/progressBar2" s ...

  5. 第一百九十八节,jQuery EasyUI,ProgressBar(进度条)组件

    jQuery EasyUI,ProgressBar(进度条)组件 学习要点: 1.加载方式 2.属性列表 3.事件列表 4.方法列表 本节课重点了解 EasyUI 中 ProgressBar(进度条) ...

  6. EasyUI系列学习(八)-ProgressBar(进度条)

    一.创建组件 1.class加载 <div class="easyui-progressbar"></div> 2.js加载 <div id=&quo ...

  7. Tkinter 之ProgressBar进度条标签

    一.参数说明 参数 作用 cursor 鼠标位于进度条内时的形状 length 进度条长度 maximum 进度条最大刻度值 mode  进度条的模式.有两种:‘determinate’和’indet ...

  8. android ProgressBar 进度条的进度两端是圆角的方法

    转自 http://www.jianshu.com/p/6e7ea842d5ce 另外工作原理可以参考http://blog.csdn.net/lan603168/article/details/44 ...

  9. Android -- ProgressBar(进度条的使用)

    我们在开发程序是经常会需要软件全屏显示.自定义标题(使用按钮等控件)和其他的需求,今天这一讲就是如何控制Android应用程序的窗体显示. requestWindowFeature可以设置的值有:(具 ...

随机推荐

  1. OC 对象和函数

    #import <Foundation/Foundation.h> @interface Car : NSObject {// 成员变量 @public int wheels; int s ...

  2. dbvis的使用

    Dbvise的使用

  3. typedef struct用法详解与小结

    1.基本解释 typedef为C语言的关键字,作用是为一种数据类型定义一个新名字,这里的数据类型包括内部数据类型(int,char等)和自定义的数据类型(struct等). 在编程中使用typedef ...

  4. dom4j解析xml报错:Nested exception: org.xml.sax.SAXParseException: White space is required between the processing instruction target and data.

    采用dom4j方式解析string类型的xml xml:        String string="<?xmlversion=\"1.0\" encoding=\ ...

  5. hibernate 各种主键生成策略(转)

    http://www.cnblogs.com/kakafra/archive/2012/09/16/2687569.html 1.assigned 主键由外部程序负责生成,在 save() 之前必须指 ...

  6. L222 词汇题

    Some psychologists argue that the traditional idea “spare the rod and spoil the child” is not ration ...

  7. jQuery一句话实现全选

    一句话实现全选 function selectAll(checkbox){ $('input[type=checkbox]').prop('checked', $(checkbox).prop('ch ...

  8. [HTML]去除li前面的小黑点,和ul、LI部分属性

    [转] 对于很多人用div来做网站时,总会用到,但在显示效果时前面总是会有一个小黑点,这个令很多人头痛,但又找不到要源,其它我们可以用以下方法来清除.[HTML]去除li前面的小黑点,和ul.LI部分 ...

  9. C# winform 编程 向ACCESS数据库导入EXCEL表使用心得

    public string MyConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=ErLake.mdb&quo ...

  10. Incremental Method

    「遞增法」是符合電腦運作特性的方法.電腦執行程式,一次只做一個動作,完成了一件事才做下一件事.當一個問題太大太多時,化整為零.一個一個解決吧! 合抱之木,生於毫末:九層之臺,起於累土:千里之行,始於足 ...