Click here to Skip to main content
15,889,471 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to show progress bar in DataGrid during the processing period in a windows Application using c#. I need to show the same in the cell content click event of a data gridview, on form load, on button click etc.

What I have tried:

Code as below:
Cell Content Event
C#
if (e.ColumnIndex == 5 && e.RowIndex >= 0)
      {
          this.grdAppPools.CommitEdit(DataGridViewDataErrorContexts.Commit);
          //Creation of Application Pool
          #region CreateAppPool
          if ((bool)this.grdAppPools.CurrentCell.Value == true)
          {
              try
              {
                  Common.WriteLog("Application Pools Creation Process Started in the Server " + ServerName, LogPath);
                  IIS_Service_Mngr objmngr = new IIS_Service_Mngr();
                  string strOutputMsg = string.Empty;
                  //create Application Pool with parameters (poolname,Enable32bit,Mode(integrated/classic),runtimeVersion(2.0/4.0)
                  if (objmngr.CreateAppPool(grdAppPools.Rows[e.RowIndex].Cells[1].Value.ToString(), Boolean.Parse(grdAppPools.Rows[e.RowIndex].Cells[4].Value.ToString()), grdAppPools.Rows[e.RowIndex].Cells[2].Value.ToString(), grdAppPools.Rows[e.RowIndex].Cells[3].Value.ToString(), ServerName, ref strOutputMsg))
                  {
                      grdAppPools.Rows[e.RowIndex].Cells[5].Value = 1; //Select check box state with in the Apppool gridview
                      grdAppPools.Rows[e.RowIndex].Cells[6].Value = "Installed";

                      //Update Application Pool Status in Xml File Configured in app.config
                      #region Update Application Pool Status in Xml File Configured in app.config
                      Common.UpdateXmlSchema_Config(ApplicationPool_XmlFilePath, "ApplicationPool", "Installed", e.RowIndex);
                      #endregion


                  }
                  else
                  {
                      grdAppPools.Rows[e.RowIndex].Cells[5].Value = 1; //Select check box state with in the Apppool gridview
                      grdAppPools.Rows[e.RowIndex].Cells[6].Value = "Failed";

                      //Update Application Pool Status in Xml File Configured in app.config
                      #region Update Application Pool Status in Xml File Configured in app.config
                      Common.UpdateXmlSchema_Config(ApplicationPool_XmlFilePath, "ApplicationPool", "Failed",e.RowIndex);
                      #endregion


                  }

                  dtAppPools.AcceptChanges();
                  grdAppPools.DataSource = dtAppPools;

                  if (!string.IsNullOrEmpty(strOutputMsg))
                  {
                      MessageBox.Show(strOutputMsg);

                  }
                  Common.WriteLog("Application Pools Creation Process Completed in the Server " + ServerName, LogPath);
              }
              catch (Exception ex)
              {
                  Common.WriteLog("Application Pool Creation Process Failed in the Method " + MethodInfo.GetCurrentMethod() + " with Exception " + ex.Message + "with inner Exception " + ex.InnerException + "at " + ex.StackTrace.ToString() + "in the Server " + ServerName + Environment.NewLine, LogPath);

              }
          }
          #endregion
Posted
Updated 18-Aug-19 19:48pm
v3

1 solution

 
Share this answer
 
Comments
ranio 19-Aug-19 4:35am    
Above link is being shown simply as a static progress bar column with percentage but not in a dynamic way.
Maciej Los 19-Aug-19 4:41am    
What you mean by 'static'?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900