Make a claas like this one to create ProgressBar :-
public class StatusProgressBar : ToolStripProgressBar
{
#region Private Fields
private static StatusProgressBar _instance = null;
#endregion
#region Constructor
private StatusProgressBar()
{
this.Style = ProgressBarStyle.Blocks;
this.Step = 1;
}
#endregion
#region Properties
///
/// Get Singleton instance of progressBar
///
public static StatusProgressBar Instance
{
get
{
if (_instance == null)
{
_instance = new StatusProgressBar();
}
return _instance;
}
}
#endregion
}
Now main issue how to increase the bar and how calculate the percentage then firstly i would say calculate numer of lines to be read or parsed in amy editor according to your application
public const char NEWLINE_CHARACTER = '\n';
string[] lines = t.Split(NEWLINE_CHARACTER);
This will perform for all the lines and lines will be incremented then progress bar will be increemented accordingly.
for (int lineIndex = 0; lineIndex < lines.Length; lineIndex++)
{
if (lineIndex % 2 == 0)
{
StatusProgressBar.Instance.PerformStep();
StatusProgressBar.Instance.ToolTipText = Convert.ToString((StatusProgressBar.Instance.Value / StatusProgressBar.Instance.Maximum) * 100) + "%";
}
}
Happy to code................
public class StatusProgressBar : ToolStripProgressBar
{
#region Private Fields
private static StatusProgressBar _instance = null;
#endregion
#region Constructor
private StatusProgressBar()
{
this.Style = ProgressBarStyle.Blocks;
this.Step = 1;
}
#endregion
#region Properties
///
/// Get Singleton instance of progressBar
///
public static StatusProgressBar Instance
{
get
{
if (_instance == null)
{
_instance = new StatusProgressBar();
}
return _instance;
}
}
#endregion
}
Now main issue how to increase the bar and how calculate the percentage then firstly i would say calculate numer of lines to be read or parsed in amy editor according to your application
public const char NEWLINE_CHARACTER = '\n';
string[] lines = t.Split(NEWLINE_CHARACTER);
This will perform for all the lines and lines will be incremented then progress bar will be increemented accordingly.
for (int lineIndex = 0; lineIndex < lines.Length; lineIndex++)
{
if (lineIndex % 2 == 0)
{
StatusProgressBar.Instance.PerformStep();
StatusProgressBar.Instance.ToolTipText = Convert.ToString((StatusProgressBar.Instance.Value / StatusProgressBar.Instance.Maximum) * 100) + "%";
}
}
Happy to code................