Unable to display full image in datagridview cell

I have a data grid view with a product name and a product name, and I populate these values ​​coming from the database ...

I am using winforms desktop application .....

my problem is that I cannot correctly display the image in the datagridview cell. Check out the chart below.total grid view image

I want to display this image in the actual product image column for each cell in this column actual image need to show in every row

this task is very simple in webforms using the datalist control, but I don't know how to display the full image in a grid cell.

can anyone help with this ....

many thanks.......

and this is where I bind datagridview with linq query ..

      private void EquipmentFinder_Load(object sender, EventArgs e)
     {

        var products = from prods in abc.products
                       select new
                       {
                           productid = prods.product_Id,   //0                            
                           productname =  prods.product_Name, //1
                           productimage = prods.product_Image, //2
                           productprice = prods.product_Price,//3
                           productdescr = prods.product_Description, //4

                       };
        productbindingsource.DataSource = products;
        productgridview.DataSource = productbindingsource;
        productgridview.Columns[0].Visible = false;
        productgridview.Columns[3].Visible = false;
        productgridview.Columns[4].Visible = false;
    }
+5
3

ImageLayout Stretch .

UPDATE: , ImageLayout:

for(int i = 0; i < dataGridView1.Columns.Count; i ++)
                if(dataGridView1.Columns[i] is DataGridViewImageColumn) {
                    ((DataGridViewImageColumn)dataGridView1.Columns[i]).ImageLayout = DataGridViewImageCellLayout.Stretch;
                    break;
                }
+9

DataGridViewImageColumn.ImageLayout DataGridViewImageCellLayout.Zoom

"", . , , , .

, , .

"": .

0

first right-click on the grid, go to the properties of the grid in which you get the properties of the column (collection), click on it. click on the image column in which the appearance layout will be displayed - and select the stretch property, you can also increase the size of the image column. its really useful in this case. You do not need such a code.

0
source

All Articles