vb.net中的动态图像控制

时间:2013-06-19 07:32:46

标签: vb.net

我需要在vb.net中动态创建一个图像控件。在声明new image(dim img as New Image()时,它显示以下错误:

  

错误:New不能在MustInherit

的类中使用

有什么解决方案吗?这是我需要使用它的地方:

Dim imgBox As New Image()
imgBox.ImageUrl = "~/Images/" & strImgName
Dim tr As New TableRow
Dim tdRight As New TableCell
Dim tdLeft As New TableCell
tdRight.Controls.Add(imgBox)
tdLeft.Controls.Add(imgBox)
tr.Controls.Add(tdLeft)   'adding left cell
tr.Controls.Add(tdRight)  'adding right cell
tb.Controls.Add(tr) 

1 个答案:

答案 0 :(得分:2)

您似乎正在Image命名空间中获取System.Drawing类,因为该类是抽象的。如果您已包含System.Drawing命名空间,则必须指定要使用的Image类的位置。

例如:

Dim imgBox As New System.Windows.Controls.Image()
相关问题