how i can run a progress bar on winform to tell the user to wait till the xml file is being uploaded in treeview on winform?
i am getting an exception on xmlDocument.Load(txtFileName.Text);
Thanks
private void btnBrowse_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
if (open.ShowDialog(this) == DialogResult.OK)
{
txtFileName.Text = open.FileName;
treeDocLoadMethod(open.FileName); //this variable gives the name of selected file
bgWorker.RunWorkerAsync();
}
}//Browse button
private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
{
xmlDocument = new XmlDocument();
Thread.Sleep(500);
xmlDocument.Load(txtFileName.Text);
btnBrowse.Enabled = false;
}
private void bgworker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
// Set progress bar to 100% in case it's not already there.
StripProgressBar.Value = 100;
if (e.Error == null)
{
MessageBox.Show(xmlDocument.InnerXml, "Download Complete");
}
else
{
MessageBox.Show("Failed to download file");
}
// Enable the Browse button and reset the progress bar.
this.btnBrowse.Enabled = true;
StripProgressBar.Value = 0;
toolStripStatusLabel1.Text = "work finished processing request.";
}//workerCompleted
Vimal KandasamyPosted Mar 5, 2009, 8:06 AM
please read following articles about progress bar
Article1
Article 2
Rach SinghPosted Mar 5, 2009, 7:10 AM
I have checked my part of code as per your mail.
i could not found anything wrong in property box.
i have not declared anything about progress bar in the Browse button clik event and bgwrker_DoEvent().
I dont know where excatly can i check the working of my progress bar .
The part of the code which i have posted is correct as you suggested.
Then where can i find the error?
If you dont mind please help me telling the syntax/steps to get my progress bar work.
Since i am a beginner in C# so have very little idea about the GUI related events
Thanks..
Vimal KandasamyPosted Mar 5, 2009, 5:09 AM
hi
nothing wrong in your code, i think so.check the creation and settings of your progress bar.and make sure after selection of a file,progress bar starts and after end of upload its filled with 100%.... before going to file upload... you check your progress bar alone whether its worked or not... later check it with file uploading
Rach SinghPosted Mar 5, 2009, 3:44 AM
i got hold of exception it was because i was calling empty string in the textbox through RunworkAsync().i have updated the code in my question.please do have a look.
But the problem is now that the progress bar is not working the file gets uploaded but the progress bar dosen't start on my winform.
waiting to hear from u.
Thanks..
Vimal KandasamyPosted Mar 2, 2009, 7:46 AM
may i know what is the exception occurred on xml document loading?