The ProgressBar control that is included with Microsoft Visual C# supports only the standard setting.
The sample code in this article illustrates how to create a control that supports the following properties:
• Minimum. This property obtains or sets the lower value for the range of valid values for progress. The default value of this property is zero (0); you cannot set this property to a negative value.
• Maximum. This property obtains or sets the upper value for the range of valid values for progress. The default value of this property is 100.
• Value. This property obtains or sets the current level of progress. The value must be in the range that the Minimum and the Maximum properties define.
• ProgressBarColor. This property obtains or sets the color of the progress bar.
For example Progressbar in C#
Source Code
----------------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace PNbrowser
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e)
{
}
private void buttonGo_Click(object sender, EventArgs e)
{
if (!textBoxAddress.Text.Equals(""))
webBrowser1.Navigate(textBoxAddress.Text);
}
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.GoHome();
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
this.Text ="PNbrowser "+ webBrowser1.DocumentTitle;
}
private void buttonHome_Click(object sender, EventArgs e)
{
webBrowser1.GoHome();
// textBoxAddress.Text=webBrowser1.
}
private void buttonBack_Click(object sender, EventArgs e)
{
webBrowser1.GoBack();
}
private void buttonNext_Click(object sender, EventArgs e)
{
webBrowser1.GoForward();
}
private void webBrowser1_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e)
{
toolStripStatusLabelStatus.Text = webBrowser1.StatusText;
int process=(int)(e.CurrentProgress * 100 / e.MaximumProgress);
if (process >0)
{
if (process > 100)
process =99;
toolStripProgressBar.Visible = true;
toolStripStatusLabelProcessing.Text = "processing = " + (process) + "%";
toolStripProgressBar.Value = process;
}
if ((process >=100)||(process<0))
{
toolStripProgressBar.Visible = false;
toolStripStatusLabelProcessing.Text = "";
}
}
private void internetOptionToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("inetcpl.cpl");
}
private void buttonSearch_Click(object sender, EventArgs e)
{ if(!textBoxSearch.Text.Equals(""))
webBrowser1.Navigate("http://www.google.co.th/search?hl=th&q=" + textBoxSearch.Text);
}
private void timeDateToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("timedate.cpl");
}
}
}
End Source code
End Progressbar C#
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment