0

hello all
In a cells of a datagridview I place a gif image name new.gif .

I can show it immediately after the the form load even

I try to print this datagridview cell(0,0) value which is an image name new gif:

Object imgobj= dataGridView1.Rows[0].Cells[0].Value;

but then I do not know how to change this imgobj to something which can be printed
and the printed result show the "new.gif" image
hope someone teach me please

thank you
denny

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by dennysimon
0

Why you dont get the image directly out of the cell? You dont need to parse it to object.

Example:

public Form1()
        {
            InitializeComponent();
            //creating image column:
            DataGridViewImageColumn imageColumn = new DataGridViewImageColumn();
            {
                imageColumn.Name = "colImages";
                imageColumn.HeaderText = "Images";
                imageColumn.Width = 100;
                imageColumn.ImageLayout = DataGridViewImageCellLayout.Normal;
                imageColumn.CellTemplate = new DataGridViewImageCell(false);
                imageColumn.DefaultCellStyle.NullValue = null;
            }
            //adding column to dgv:
            dataGridView1.Columns.Add(imageColumn);

            //adding one image to cell of dgv:
            dataGridView1.Rows.Add();
            Image pic= Image.FromFile(@"C:\1\backward.png");
            dataGridView1[0, 0].Value = pic;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //retreiving image form dgv:
            Image img = (Image)dataGridView1[0, 0].Value;
        }

Edited by Mitja Bonca: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.