以编程方式将图片从我的资源设置为PictureBox
问题描述:
如何将图片设置为 PictureBox 在代码中?
How can I set a picture to a PictureBox in code?
下面的代码给我错误:
无法将位图隐式转换为 字符串.
Cannot implicitly convert Bitmap to String.
private void ptbLocalidadAdd_MouseEnter(object sender, EventArgs e)
{
ptbLocalidadAdd.ImageLocation = Properties.Resources.addg;
}
答
如果资源是位图,这应该可以工作:
If the resource is a bitmap, this should work:
ptbLocalidadAdd.Image = Properties.Resources.addg;