[英]Marquee Progressbar without EnabledVisualStyles()
创建用户控件,在其中放置一个面板,将其停靠在父容器中。 控制一个计时器。 您的用户控制代码应类似于:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProgressBar
{
public partial class PBar : UserControl
{
public PBar()
{
InitializeComponent();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
int incre = 0;
private void timer1_Tick(object sender, EventArgs e)
{
int width = 15;
int gap = 5;
Graphics g = panel1.CreateGraphics();
g.Clear(panel1.BackColor);
SolidBrush blueBrush = new SolidBrush(Color.DarkBlue);
g.FillRectangle(blueBrush, new Rectangle(new Point(incre, 0), new Size(width, panel1.Height - 1)));
g.FillRectangle(blueBrush, new Rectangle(new Point(incre + width + gap, 0), new Size(width, panel1.Height - 1)));
g.FillRectangle(blueBrush, new Rectangle(new Point(incre + 2 * (width + gap), 0), new Size(width, panel1.Height - 1)));
g.FillRectangle(blueBrush, new Rectangle(new Point(incre + 3* (width + gap), 0), new Size(width, panel1.Height - 1)));
incre += 10;
if (incre > panel1.Width)
incre = 0;
}
}
}
生成您的应用程序并将您的用户控件拖到窗体中。 根据您的要求修改代码和变量的值。
您可以将图片框与gif图像一起使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.