Setting a picture from my Resources programmatically to a PictureBox

这一生的挚爱 提交于 2019-12-11 03:29:46

问题


How can I set a picture to a PictureBox in code?

The code below gives me the error:

Cannot implicitly convert Bitmap to String.

    private void ptbLocalidadAdd_MouseEnter(object sender, EventArgs e)
    {
        ptbLocalidadAdd.ImageLocation = Properties.Resources.addg;
    }

回答1:


If the resource is a bitmap, this should work:

ptbLocalidadAdd.Image = Properties.Resources.addg;


来源:https://stackoverflow.com/questions/3845500/setting-a-picture-from-my-resources-programmatically-to-a-picturebox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!