Click here to Skip to main content
15,897,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i need one help please guide me .
i have a datagridview (window application) in C#. and i have uploaded images inside the datagridview cell.but images sizes are big so cell size is also becoming broad.
i want customize the size of the images cell.
and rest of the cells should be same .
how i can do it please give me some suggestion.
Posted
Comments
Thava Rajan 27-May-15 10:23am    
what do you expect is already there, use autoresize option in the Datagridview property

1 solution

The size of a datagridview cell is determined by the column Width and row Height. Therefore in order to change the cell's size, you must change the cells column width, and the cells row height.

C#
Image image = Image.FromFile("something.png")
int width = image.Width;
int height = image.Height;
int rowIndex = 0;

// Assumes the "images" column is a DataGridViewImageColumn
DataGridViewCell cell = dataGridView1.Rows[rowIndex].Cells["images"];
cell.Value = image;

// Set the Row height.
dataGridView1.Rows[cell.RowIndex].Height = image.Height;

// Set the Column height.
dataGridView1.Columns["images"].Width = image.Width;


C#

 
Share this answer
 

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