为大图像格式化datagridview单元格大小 [英] formating datagridview cell size for large image

查看:76
本文介绍了为大图像格式化datagridview单元格大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个帮助,请指导我。

我在C#中有一个datagridview(窗口应用程序)。我已经在datagridview cell中上传了图片。但是图片大小很大,所以单元格大小也变得很宽。

i想要自定义图像单元格的大小。

和休息单元格应该是一样的。

我怎么做才能给我一些建议。

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.

推荐答案

datagridview单元格的大小是由列宽和行高确定。因此,为了更改单元格的大小,您必须更改单元格列宽度和单元格行高。



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.

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;









这篇关于为大图像格式化datagridview单元格大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆