1.processbar例子
public
partial
class DlgProgressBar : DevExpress.XtraEditors.XtraForm
{
public DlgProgressBar( int BarMaxValue, int BarMinValue)
{
InitializeComponent();
// 设置一个最小值
progressBarControl1.Properties.Minimum = BarMaxValue;
// 设置一个最大值
progressBarControl1.Properties.Maximum = BarMinValue;
// 设置步长,即每次增加的数
progressBarControl1.Properties.Step = 1;
// progressBarControl1.Properties.ProgressViewStyle = DevExpress.XtraEditors.Controls.ProgressViewStyle.Solid;
progressBarControl1.Position = 0;
}
public void SetBarValue( string msgString, int barValue)
{
for ( int i = 0; i < barValue; i++)
{
Application.DoEvents();
progressBarControl1.PerformStep();
this.lblMsg.Text = msgString+ " ... ";
System.Threading.Thread.Sleep( 15);
}
if (barValue == 0)
{
Application.DoEvents();
this.lblMsg.Text = msgString + " ... ";
System.Threading.Thread.Sleep( 15);
}
}
}
{
public DlgProgressBar( int BarMaxValue, int BarMinValue)
{
InitializeComponent();
// 设置一个最小值
progressBarControl1.Properties.Minimum = BarMaxValue;
// 设置一个最大值
progressBarControl1.Properties.Maximum = BarMinValue;
// 设置步长,即每次增加的数
progressBarControl1.Properties.Step = 1;
// progressBarControl1.Properties.ProgressViewStyle = DevExpress.XtraEditors.Controls.ProgressViewStyle.Solid;
progressBarControl1.Position = 0;
}
public void SetBarValue( string msgString, int barValue)
{
for ( int i = 0; i < barValue; i++)
{
Application.DoEvents();
progressBarControl1.PerformStep();
this.lblMsg.Text = msgString+ " ... ";
System.Threading.Thread.Sleep( 15);
}
if (barValue == 0)
{
Application.DoEvents();
this.lblMsg.Text = msgString + " ... ";
System.Threading.Thread.Sleep( 15);
}
}
}
2.RepositoryItemProgressBar
private
void ShowMsg(DevExpress.XtraBars.BarEditItem item,
string msgString)
{
if ( this.InvokeRequired == true)
{
this.Invoke((MethodInvoker) delegate { item.EditValue = msgString; });
}
else
{
item.Caption = msgString;
}
}
{
if ( this.InvokeRequired == true)
{
this.Invoke((MethodInvoker) delegate { item.EditValue = msgString; });
}
else
{
item.Caption = msgString;
}
}
下面开始调用
int processCurrent=0;
processCurrent++;
ShowMsg(pssbState, processCurrent.ToString());