Unable to display the full image in datagridview cell
Set the column's ImageLayout to the Stretch value to resolve this problem.
UPDATE: use the following code to change the ImageLayout property:
for(int i = 0; i < dataGridView1.Columns.Count; i ++)
if(dataGridView1.Columns[i] is DataGridViewImageColumn) {
((DataGridViewImageColumn)dataGridView1.Columns[i]).ImageLayout = DataGridViewImageCellLayout.Stretch;
break;
}
Glory Raj
working as a software developer.... At present doing web applications and learning Asp.net MVC..
Updated on June 09, 2022Comments
-
Glory Raj about 2 years
I have data grid view with columns product name and product image and I am populating these values coming from database...
i am using winforms desktop application.....
my problem is I am not able to showing the image in datagridview cell properly ..see the diagram below
i want to display this image in actual product image column for every cell in that column
this task is very simple in webforms by using datalist control but i dont know how to display full image in grid view cell
can any one help on this....
many thanks.......
and this is where i am binding the datagridview by using 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; }
-
Glory Raj almost 13 yearsI am not defining columns from designer i am just binding details from database using linq query
-
Glory Raj almost 13 yearshow to find the gridviewimagecolumn .. i dint touch the designer.cs see my updated code..
-
platon almost 13 yearspaste my code below this one: productgridview.Columns[4].Visible = false; The DataGridViewImageColumn is a type declared in the System.Windows.Forms namespace. Please also refer to the msdn.microsoft.com/en-us/library/…
-
Glory Raj almost 13 yearsthanq its working now ... is it possible to increase the width and height of the cell like medium sized square box....would you pls give suggestions ...
-
Glory Raj almost 13 yearsit does not working i have done like this productgridview.RowTemplate.Height = 200;
-
Glory Raj almost 13 yearsits not working .....would you pls suggest any other way to increase the width and height of each cell