这样的一个控件 肯定得通过自定义控件来实现了

 public class ProcessLabel : Control
{ public ProcessLabel()
{ //InitializeComponent();
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true); } private int distance = ; public int Distance
{
get { return distance; }
set
{
distance = value;
Invalidate();
}
} private ImageList imagelist = new ImageList(); public ImageList ImageList
{
get { return imagelist; }
set
{
imagelist = value;
Invalidate();
}
} private List<KeyValuePair<string, string>> links = new List<KeyValuePair<string, string>>(); public List<KeyValuePair<string, string>> Links
{
get { return links; }
set
{
links = value;
Invalidate();
}
} protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
Font enFont = new Font("新宋体", , FontStyle.Bold);
Rectangle rect = pe.ClipRectangle;
Graphics g = pe.Graphics;
float x = ;
float y = ;
float x1 = ;
float y1 = ;
float x2 = ;
float y2 = ;
int index = ;
if (Links.Count > )
{
foreach (KeyValuePair<string, string> kv in Links)
{
g.DrawString(kv.Key, enFont, new SolidBrush(Color.DodgerBlue), x, y);
SizeF sf = g.MeasureString(kv.Key, enFont);
x += (sf.Width + distance);
if (imagelist.Images.Count > )
{
Pen blackPenLeft;
Pen blackPenRight;
if (!string.IsNullOrEmpty(kv.Value))
{
x1 = x - distance - sf.Width / - imagelist.Images[].Width / ;
y1 = sf.Height;
g.DrawImage(imagelist.Images[], x1, y1);
blackPenLeft = new Pen(Color.Orange, );
x2 = x1 - ;
y2 = y1 + imagelist.Images[].Height;
g.DrawString(kv.Value, enFont, new SolidBrush(Color.DodgerBlue), x2, y2);
}
else
{
x1 = x - distance - sf.Width / - imagelist.Images[].Width / ;
y1 = sf.Height;
g.DrawImage(imagelist.Images[], x1, y1);
blackPenLeft = new Pen(Color.Black, );
}
if (index + < Links.Count && !string.IsNullOrEmpty(Links[index + ].Value))
{
blackPenRight = new Pen(Color.Orange, );
}
else
{
blackPenRight = new Pen(Color.Black, );
}
if (index == )
{
g.DrawLine(blackPenRight, x1 + imagelist.Images[].Width, y1 + imagelist.Images[].Height / , x1 + imagelist.Images[].Width / + sf.Width / + distance / , y1 + imagelist.Images[].Height / );
}
else if (index == Links.Count - )
{
g.DrawLine(blackPenLeft, x1 - , y1 + imagelist.Images[].Height / , x1 - sf.Width / - distance / , y1 + imagelist.Images[].Height / );
}
else
{
g.DrawLine(blackPenRight, x1 + imagelist.Images[].Width, y1 + imagelist.Images[].Height / , x1 + imagelist.Images[].Width / + sf.Width / + distance / , y1 + imagelist.Images[].Height / );
g.DrawLine(blackPenLeft, x1 - , y1 + imagelist.Images[].Height / , x1 - sf.Width / - distance / , y1 + imagelist.Images[].Height / );
}
index++;
}
}
if (x - distance + < this.Parent.Width)
{
this.Width = this.Parent.Width;
}
else
{
this.Width = Convert.ToInt32(x - distance + );
}
} } }

使用

 ImageList myImageList = new ImageList();
string filePath1 = Application.StartupPath + "\\Images\\orangelink.png";
string filePath2 = Application.StartupPath + "\\Images\\blacklink.png";
myImageList.Images.Add(Image.FromFile(filePath1));
myImageList.Images.Add(Image.FromFile(filePath2));
processLabel1.ImageList = myImageList; List<KeyValuePair<string, string>> source = new List<KeyValuePair<string, string>>();
source.Add(new KeyValuePair<string,string>("下单","08:20"));
source.Add(new KeyValuePair<string,string>("接单","14:20"));
source.Add(new KeyValuePair<string,string>("配送","14:20"));
source.Add(new KeyValuePair<string, string>("收货", "15:20"));
source.Add(new KeyValuePair<string, string>("退货", "17:20"));
source.Add(new KeyValuePair<string, string>("退款", "19:20"));
source.Add(new KeyValuePair<string, string>("完毕", "21:20")); processLabel1.Links = source;

winform之自定义控件的更多相关文章

  1. WPF中添加Winform用户自定义控件

    过程:创建WPF工程->创建Winform用户自定义控件工程->WPF中引用控件->添加到Xaml页面 1.首先在WPF工程的解决方案上右击选择添加新建项目: 选择Windows窗体 ...

  2. WinForm GDI+自定义控件总结(一)

    前言 由于项目的原因好久没写博客了,也正是项目的原因开始系统的学习WinForm,从而接触到自定义控件的开发.自定义控件的开发有一定的难度,对开发者要求比较高,需要了解Windows运行的机制,熟悉w ...

  3. WinForm(C#)自定义控件之——RoundButton(圆形按钮)

    最近需要做一个圆形的按钮,去CodeProject找了一下,发现有现成的可用,但不能完全满足我的需求.因此自己试着利用WinForm中的自定义组件功能,制作一个圆形按钮.圆形按钮小制作即将开始之前,先 ...

  4. winform制作自定义控件(入门)

    原文链接:http://blog.csdn.net/bychentufeiyang/article/details/7081402   与原文基本一致,只是例子变成VS2012环境,语言采用博主常用的 ...

  5. WinForm创建自定义控件

    虽然VS为我们提供了很多控件可以使用,但有时候这些控件仍然不能满足我们的要求,比如我们要对部分控件进行一些个性化的定制,例如美化控件,这时候就需要自己绘制控件,或是在原有控件的基础上进行修改 自定义控 ...

  6. winform制作自定义控件

    一 .概述Windows 窗体控件是可再次使用的组件,它们封装了用户界面功能,并且可以用于客户端 Windows 应用程序.“Windows 窗体”不仅提供了许多现成控件,还提供了自行开发控件的基础结 ...

  7. WinForm用户自定义控件,在主窗体加载时出现闪烁;调用用户控件出现闪烁,需要鼠标才能够显示

    转载自:http://www.dotblogs.com.tw/rainmaker/archive/2012/02/22/69811.aspx 解决方案: 在调用用户控件的窗体里面添加一下代码: pro ...

  8. Winform 中 DesignMode 返回值不正确的问题。

    本文转载:http://blog.csdn.net/sabty/article/details/5325260 以前也曾遇到这样的问题,不过影响不大也没有去详细了解.今天又重新遇到此问题,实在太不便. ...

  9. Winform下让你的DataGridView控件支持点语法(即显示list中的子对象属性)

    前言: 不想看前言的直接去看正文吧!另外文末有彩蛋. DataGridView可以支持多种数据源格式,比如DataTable和List. DataTable没啥特殊的,本身就是一张二维的表,可以和Da ...

随机推荐

  1. Lintcode: Partition Array

    Given an array "nums" of integers and an int "k", Partition the array (i.e move ...

  2. 【Origin】羡旁人

    -道行至一桥畔,微风轻抚,观河岸杨柳柳枝空舞,看满路车辆畅行无阻,虽羡,然各有归途. 小河岸,棵棵杨柳,柳枝随风摆; 大路上,盏盏绿灯,一路往北开. 横批: 可惜不是我 -作于二零一六年三月二十二日

  3. CSS3 filter:drop-shadow滤镜与box-shadow区别应用 抄的

    CSS3 filter:drop-shadow滤镜与box-shadow区别应用 这篇文章发布于 2016年05月18日,星期三,01:07,归类于 css相关. 阅读 5777 次, 今日 12 次 ...

  4. mongodb聚合内存不足解决方案

    原因:mongodb每一个文档默认只有16M.聚合的结果是一个BSON文档,当超过16M大小时,就会报内存不够错误. exceeded memory limit for $group.but didn ...

  5. spring中的bean后处理器

    package com.process; import org.springframework.beans.BeansException; import org.springframework.bea ...

  6. 【php】目录、路径和文件 操作

    目录操作 解析路径: basename() - 返回路径的文件名部分 获取目录部分: dirname() - 返回路径的目录部分 路径信息: pathinfo() - 返回数组(目录名,基本名,扩展名 ...

  7. string与char之间的互相转换

    string对象是一种很强大的存在哈~~ 1. string转const char* string s = "abc"; const char* c_s = s.c_str(); ...

  8. MySQL rename database如何做?

    虽然MySQL里面有rename database的语法,但是只是在5.1.7 to 5.1.23提供的,其他版本并没有,要想做rename操作该如何做呢?percona提供了一个shell #!/b ...

  9. 使用BusyBox制作根文件系统【转】

    本文转载自:http://www.cnblogs.com/lidabo/p/5300180.html 1.BusyBox简介 BusyBox 是很多标准 Linux 工具的一个单个可执行实现.Busy ...

  10. TM1680的I2C的51例程

    搞到一个例程,虽然是51的, 但是我的ST版本也是用的模拟I2C, 分析一下吧: unsigned char i=0;TM1680start();  //I2C起始信号 TM1680SendByte( ...