【问题标题】:Value of type 'String' cannot be converted to 'System.Drawing.Image'“String”类型的值无法转换为“System.Drawing.Image”
【发布时间】:2014-08-02 10:40:41
【问题描述】:
PictureBox1.Image = "WindowsApplication4.My.Resources.Resources._" & itemno.Text

您好,我有一堆图片,编号为 (1-100),当用户在“itemno”输入框中输入数字时,picturebox1.image 会相应更改。我如何实现上面代码示例中的内容?

【问题讨论】:

    标签: vb.net string typeconverter


    【解决方案1】:

    您可以使用ResourceManager 按名称获取资源。

    PictureBox1.Image = DirectCast(My.Resources.ResourceManager.GetObject("name_of_image"), Bitmap)
    

    【讨论】:

    • 谢谢! PictureBox1.Image = DirectCast(My.Resources.ResourceManager.GetObject("_" & itemno.Text), Bitmap) 成功了!!
    猜你喜欢
    • 2019-05-15
    • 2015-08-14
    • 2012-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多