The use of progressbarcontrol, a progress bar control of devexpress – Taking ZedGraph as an example to add curve progress



WinForm control – devexpress18 download installation registration and use in vs:

When using ZedGraph to add curves, the number of curves is slower if there are many cases.

So in the process of adding curve, the progress needs to be displayed, and the effect is as follows




Blog home page:

Pay attention to the public address
Domineering procedural ape
Get programming related ebooks, tutorials and free downloads.


Open the designer on the page where you want to add a progress bar, and drag a progressbarcontrol in the toolbox where devxpress is installed




Then set some properties of the progress bar control in the construction method of the current form

public FrmCurveCompareInOne()
            progressBarControl1.Visible = true;
            //Set a minimum
            progressBarControl1.Properties.Minimum = 0;
            //Set a maximum
            progressBarControl1.Properties.Maximum = 100;
            //Style progress bar
            progressBarControl1.Properties.ProgressViewStyle = DevExpress.XtraEditors.Controls.ProgressViewStyle.Solid;
            // current value
            progressBarControl1.Position = 0;
            //Show progress data or not
            progressBarControl1.Properties.ShowTitle = true;
            //Show percentage or not
            progressBarControl1.Properties.PercentView = true;

The current progress bar object is then passed in the method that triggers the display of the progress bar

ChartCompareHelper.RefreshPaneComInOne(this.zedGraphControl1, xYModelStore.YAxisModelList,this.progressBarControl1);

In the method of refreshing the graph of ZedGraph above, add the part of curve to set the progress

if (yList != null && yList.Count > 0)
                PointPairList list = null;
                for (int i = 0; i < yList.Count; i++)
                    //Display 100 cycles before interception
                    Global.Instance.PrepareCompareDataInOne = Global.Instance.PrepareCompareDataInOne.Where(p => (int.Parse(p.Id) < 101)).ToList();
                    //Calculate progress bar step
                    int step = 1;
                    //The total number of curves is less than 100 
                    if (Global.Instance.PrepareCompareDataInOne.Count < 100)
                        step = 100 / Global.Instance.PrepareCompareDataInOne.Count;
                        step = Global.Instance.PrepareCompareDataInOne.Count / 100;
                    if(progressBar !=null)
                        //Initialize progress bar to 0%
                        progressBar.Position = 0;
                    //Loop add curve
                    foreach(DataTreeNode node in Global.Instance.PrepareCompareDataInOne)
                        IEnumerable record =  Global.Instance.VirtualData.RecordDataList.Where(p => p.CycleIndex == int.Parse(node.Id));
                        list = SetCurveTextInOne(yList[i].TitleKey,record);
                        LineItem myCurve = myPane.AddCurve(yList[i].Title, list, System.Drawing.ColorTranslator.FromHtml(yList[i].Color), SymbolType.None);
                        Mycurve.yaxisindex = I; // it is critical to use that coordinate value
                        if(progressBar !=null)
                            //If a curve is added successfully, the progress bar will be increased by one step
                            progressBar.Position += step;
                            if (progressBar.Position >=100)
                                //If the total progress is greater than 100, the value is 100
                                progressBar.Position = 100;
                            //Update progress bar progress
                    if (progressBar != null)
                        //Set the progress bar to 100% after adding all curves finally
                        progressBar.Position = 100;