यह मेरे लिए काम करता है। मैं आपके लिए एक अनिश्चित प्रगति पट्टी बनाते हैं। अपनी परियोजना/फार्म के लिए एक कस्टम नियंत्रण जोड़ें और यह कोड डालना:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace AnimatedCustomControls
{
sealed class IndeterminateProgressbar : Control
{
private readonly List<int> positions = new List<int>();
private readonly Timer tmrAnimation = new Timer {Interval = 5, Enabled = false};
private readonly Timer tmrAddPosition = new Timer {Interval = 500, Enabled = true};
public Color ProgressColor { get; set; }
public Color InactiveColor { get; set; }
public IndeterminateProgressbar()
{
DoubleBuffered = true;
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
ProgressColor = Color.FromArgb(40, 190, 245);
InactiveColor = Color.FromArgb(40, 40, 40);
tmrAnimation.Tick += tmrAnimation_Tick;
tmrAddPosition.Tick += tmrAddPosition_Tick;
if (!DesignMode) tmrAnimation.Start();
}
void tmrAddPosition_Tick(object sender, EventArgs e)
{
positions.Add(1);
}
void tmrAnimation_Tick(object sender, EventArgs e)
{
if (DesignMode) tmrAnimation.Stop();
for (int i = 0; i < positions.Count; i++)
{
positions[i] += 2 + Math.Abs(positions[i])/50;
if (positions[i] > Width) positions.RemoveAt(i);
}
Invalidate();
}
protected override void OnEnabledChanged(EventArgs e)
{
base.OnEnabledChanged(e);
if (Enabled)
{
positions.Clear();
positions.AddRange(new[] { Width/10, Width/3, Width/2, (int)(Width * 0.7) });
}
}
protected override void OnPaint(PaintEventArgs e)
{
if (Enabled)
{
e.Graphics.Clear(BackColor);
foreach (int i in positions)
{
e.Graphics.DrawLine(new Pen(Brushes.Black, 4f), i, 0, i, Height);
}
}
else e.Graphics.Clear(InactiveColor);
base.OnPaint(e);
}
}
}
तब आप अपने समाधान का निर्माण करना चाहिए और जब आप डिजाइनर के लिए वापस जाओ, नए नियंत्रण अपने पिटारे में होना चाहिए ।इसे अपने रूप में खींचें, अधिकतम और न्यूनतम मान सेट करें और यह सब कुछ है।
मैं एक नमूना कार्यक्रम बनाया है ताकि आप जानते हैं कि यह कैसे किया जाता है यह बताने के लिए:
private void Form1_Load(object sender, EventArgs e)
{
indeterminateProgressbar1.BackColor = Color.FromArgb(40, 190, 245); //it's an nice color ;)
indeterminateProgressbar1.Size = new Size(400, 4); //make it small in the height looks better
indeterminateProgressbar1.Visible = true;
}
स्रोत
2014-04-30 19:52:56
लगता है माइक्रोसॉफ्ट जाने नहीं दे सकता "मार्की" पूरी तरह से जाने। :- डी – Tomalak
इसे "विंडोज एक्सपी या उच्चतर" बनाएं। मैंने अभी विंडोज विस्टा और विंडोज 7 बीटा (हालांकि 64 बिट दोनों) पर परीक्षण किया है और यह काम करता है। – Joey
नोट: यह एक .NET 2.0+ सुविधा है। .NET 1.1 ने स्टाइल प्रॉपर्टी का पर्दाफाश नहीं किया। –