数据进度条

时间:2016-04-20 11:39:13

标签: c# progress-bar

我从文件中获取数据并将其添加到List中。我有一个网格,我正在将该列表添加到网格中。我希望每当列表中添加一行时,进度条值应该增加。 以及如何显示添加到列表中的数据百分比。

以下是代码: -

private void getHistory(string _usrName) // Function to get history
        {

                List<Data> _DataList = new List<Data>(); // List for Data Class Type

                _listUserDetails = new List<User>(); // List of User Class Type
                User _userClassObj = null;
                string _timeSheetDataEntries = _fileReadFunction(); // Reading File Here
                string[] _splittedTimeSheetDataEntries = _timeSheetDataEntries.Split('\n');
                if (_timeSheetDataEntries.Contains(LoginPage.ursname))
                {
                    List<string> _particularUserName = (from a in _splittedTimeSheetDataEntries
                                                        where a.Contains(LoginPage.ursname)
                                                        select a).ToList();
 foreach (var _itemInArray in _particularUserName)
                    {
                        string[] _splittedDetails = _itemInArray.Split('_');
                        _oracleDataList.Add(new OracleData(_splittedDetails[0], _splittedDetails[1], _splittedDetails[2]));
                    }
// Inside This <All Operation>
// After this Data is Added in The user type List by foreach Loop.
// Multiple rows will be added to List.
_listUserDetails.Add(_userClassObj);
// Here i want to increase the value of Progress Bar for each _userClassObj Added to list before adding the data to grid.
 _progressBar.Maximum = _listUserDetails.Count; // Maximum Size of Progress Bar.

//for Percentage i have used this code But its not Working Fine. its Shows the 100 % every time. 
 int percent = (int)(((double)_progressBar.Value / (double)_progressBar.Maximum) * 100);
                    _progressBar.CreateGraphics().DrawString(percent.ToString() + "%", new Font("Arial", (float)8.25, FontStyle.Regular), Brushes.Black, new PointF(_progressBar.Width / 2 - 10, _progressBar.Height / 2 - 7));

怎么做?

0 个答案:

没有答案
相关问题