Click here to Skip to main content
16,020,990 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have to show image from my project folder( from solution explorer) instead of pdf file names in columns where the file exists

What I have tried:

Image imgCalibration = (Image)e.RowIndex.FindControl("imgCalibration");
                  DataGridViewImageColumn img = new DataGridViewImageColumn();
              if (!string.IsNullOrEmpty(Calibaration))
              {
                  string[] Cal = Calibaration.Split('.');
                  if (Cal[1].ToString() == "pdf" || Cal[1].ToString() == "PDF")
                      //  Bitmap img = new Bitmap("~/Images/pdf.png");
                      // System.Drawing.Image imgCalibration = Image.FromFile("~/Images/pdf.png");
                      //img.Image = imgCalibration;
                      gvProduct.Rows[e.RowIndex].Cells["CalibratCertificate"].Value = Image.FromFile("~/images/pdf.png");
                  //imgCalibration.ImageUrl = "~/Images/pdf.png";
                  else if (Cal[1].ToString() == "docx" || Cal[1].ToString() == "DOCX" || Cal[1].ToString() == "doc" || Cal[1].ToString() == "DOC")
                      gvProduct.Rows[e.RowIndex].Cells["CalibratCertificate"].Value = Image.FromFile("~/images/word.png");
                  //imgCalibration.ImageUrl = "~/Images/word.png";
                  else if (Cal[1].ToString() == "xls" || Cal[1].ToString() == "XLS")
                      gvProduct.Rows[e.RowIndex].Cells["CalibratCertificate"].Value = Image.FromFile("~/images/Excel.png");
                  // imgCalibration.ImageUrl = "~/Images/Excel.png";
                  //hlCertificate.Visible = true;
              }
Posted
Comments
[no name] 9-Apr-22 7:45am    
What is the problem?
Kanaga Lakshmi from Delhi 9-Apr-22 8:41am    
how the images should be displayed instead of file names while pageLoad in C# windows forms?
[no name] 9-Apr-22 8:45am    
Please read my message again.

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