custom progress bar in a datagridview with threading

csharp , jave , c , cpp , sql Manila, Philippines
  • 10 years ago
    I am creating a program similar to a download manager. In my form(DownloadManagerForm.cs) I already created a datagridview with a custom progress bar(i found out i have to create classes called DataGridViewProgressColumn and DataGridViewProgressCell because datagridview does not support other controls). In my other class (BHO) i have to activate the DownloadManagerForm automatically and use a thread so it can facilitate multiple downloading. I used the Invoke method and a certain Callback. I noticed that when i run the program the progress bar starts with 0 then 100.I want to see the progress bar move slowly or at least see it move somehow. Please tell me what to add with my code.. columnGraphics = new DataGridViewProgressColumn(); dataGridView1.Rows.Add(columnGraphics); thrDownload = new Thread(Download); thrDownload.Start(); ----------------------------------------------- Download() { . . . this.Invoke(new UpdateProgessCallback(this.UpdateProgress), new object[] { strLocal.Length, fileSize }); } -------------------------------------- UpdateProgress { int PercentProgress = Convert.ToInt32((BytesRead * 100) / TotalBytes); updatedProgress = ((float)PercentProgress); Graphics.CellTemplate.Value = updatedProgress; } . . . Class DataGridViewProgressColumn and DataGridViewProgressCell
  • 10 years ago
    I suppose you are using some "hand written" class as [here](http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=176890&SiteID=1) is promoted. In order to use it as normall progressbar, which has Minimum And Maximum and Value property, add to it this three new properties, covering three variables, and replace concrete numbers in routines (you may find that 1 and 100 easily) with these variables. Don't forget to throw errors if maximum is updated, or to solve it correctly, while Value should fit Minimum-Maximum specified interval after Minimum or Maximum value update.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Measuring programming progress by lines of code is like measuring aircraft building progress by weight.” - Bill Gates