简体   繁体   English

Visual Studio 2013中的资源

[英]Resources in Visual Studio 2013

I am trying to add a myimage.jpg as a resource in Visual Studio 2013 for a C# project. 我正在尝试将myimage.jpg添加为Visual Studio 2013中C#项目的资源。 I need to dynamically load these resources. 我需要动态加载这些资源。 I added the myimage.jpg to the resources of the project and set it as a embedded resource. 我将myimage.jpg添加到项目的资源中,并将其设置为嵌入式资源。 Then in my code I try to use the resource by using 然后在我的代码中,我尝试通过使用资源

pictureBox1.Image = WindowsFormsApplication1.Properties.Resources.myimage

but the choices I have after Resources. 但是我在Resources.之后有很多选择Resources. are culture, equals, reference equals and resource manager. 是文化,平等,参考平等和资源管理者。 Why is myimage not a choice? 为什么myimage不是一个选择?

This works correctly for me. 这对我来说是正确的。 I added a JPG image to the resources tab in project properties, then loaded the image into a picturebox with the following code: 我在项目属性的资源选项卡中添加了JPG图像,然后使用以下代码将图像加载到图片框:

pictureBox1.Image = Properties.Resources._17080

The image appeared in the picturebox as expected. 图像按预期出现在图片框中。

This also works when I specifically reference the form: 当我专门引用该表格时,这也适用:

WindowsFormsApplication1.Properties.Resources._17080

If you are instead creating a custom resources file (Resource1.resx), then you can use this: 如果要创建一个自定义资源文件(Resource1.resx),则可以使用以下命令:

pictureBox1.Image = Resource1._17808

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM