I need to add a progress bar in a DataGridView using DataTable or DataSet in a WinForms application similar to this:
Everywhere I've found has code like:
DataGridViewProgressColumn column = new DataGridViewProgressColumn();
column.HeaderText = "Status";
dataGridView1.Columns.Add(column);
and assign value with:
object[] row1 = new object[] { "test1", "test2", 50 };
But I need this progress bar to be in a DataTable or DataSet.
So this is example from msdn, with some correction. I use Datagridview, Timer, Button.
Now you need to use thread for your computing. I hope this will help.
There is no such thing as
DataGridViewProgressColumn
. To get an actualProgressBar
column will take some work - that is aProgressBar
that is embedded inside a cell...The simplest way to achieve something like what you want is to have an animated .gif file within the relevant cell, so in this case you would use a
DatGridViewImageColumn
and select the required animate .gif as the image using a `PictureBox'.To do smoothly will require multi-threading the process that you wish to show the progress of. The basic outline of how to do this would be
Choose your animated .gif file from this amazing site.
Import a
Timer
into your form and set the timer interval as '50'.Create a picture box on you form and set its size to "1, 1" (very small) and the image source to your animated .gif.
Select this
PictureBox
as theDatGridViewImageColumn
source image.Then include the following code
This will create your animated progress image. Now all you need to worry about is not doing work on the UI thread as this will cause the animation to free along with everything else!
I hope this helps.