samedi 27 mai 2017

Add a column with an image of the invoice status Canceled or open c#

I want to put a cell in every row I have a cell that contains an invoice if it is open I want to display a certain picture and if it is closed I want to display another picture in cell

this is my code but I have Problems

error pic

this.dgvBills.DataSource = bill.SearchBills(txtSearch.Text, coBoxState.Text);
                DataGridViewImageColumn img = new DataGridViewImageColumn();
                img.Name = "img";
                img.HeaderText = "Image Column";
                img.ValuesAreIcons = true;
                dgvBills.Columns.Add(img);
                int number_of_rows = dgvBills.RowCount;
                for (int i = 0; i < number_of_rows; i++)
                {
                    if (dgvBills.Rows[i].Cells[11].Value.ToString() == "open")
                    {

                        dgvBills.Rows[i].Cells["img"].Value = pbox.Image;
                    }
                    else
                    {

                        dgvBills.Rows[i].Cells["img"].Value = pbox.InitialImage;
                    }

Aucun commentaire:

Enregistrer un commentaire