我有两种形式:一种是equipmentfinder
,另一种是productdescription
。我有一个datagridview列productname
和productimage
在equipmentfinder
形式。错误:无法将类型System.type转换为system.drawing.Image
当我点击其中一列(即)productimage
列时,它会转到另一个工作正常的页面。
我正在制作WinForms应用程序。
但我想显示在productimage
列中从datagridview在另一个picturebox在equipmentfinder
窗体中的产品图像。
所以对于我做这样的:
private void productGridview_Cellclick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == productgridview.Columns["productimage"].Index)
{
ProductDescriptionForm pf = new ProductDescriptionForm();
pf.ShowDialog(this);
}
}
和productdescription
形式我做这样的:
private void ProductDescriptionForm_Load(object sender, EventArgs e)
{
EquipmentFinder eqipu = new EquipmentFinder();
this.imagepicture.Image = (Image)eqipu.productgridview.SelectedCells.GetType();
}
,但我在这行得到了一个错误:
this.imagepicture.Image =(Image)eqipu.productgridview.SelectedCells.GetType();
Error: cannot convert type system.type To system.drawing.image
GetType为您提供单元格的类型,而不是单元格的内容作为类型。您可能想尝试放弃GetType()位,并将SelectedCell投射到图像(或单元内的项目) – tonycoupland
如何做到这一点,你会帮助... –
@tony你会帮助这个.. –