简体   繁体   English

Visual Studio图像未显示

[英]Visual Studio images not displaying

I am having a program written and I am developing on 2 different pcs. 我正在编写一个程序,并且正在2个不同的PC上进行开发。

First PC: Windows 7 Professional 64bit with VS 2015 Community. 第一台PC:带有VS 2015社区的Windows 7 Professional 64位。

Second PC: Windows 10 64bit with VS 2013. 第二台PC:带有VS 2013的Windows 10 64bit。

Problem: 问题:

On the first PC, when I build and run the program or even just run the exe, the icons for the buttons are not displaying. 在第一台PC上,当我构建并运行程序甚至运行exe时,按钮的图标均未显示。 It shows only square boxes in place of icons. 它仅显示方框代替图标。 I am getting no errors either. 我也没有错误。 Everything works fine on the second PC. 在第二台PC上一切正常。

Any idea why this may be? 知道为什么会这样吗? I have googled and cannot seem to find an answer. 我已经用谷歌搜索,似乎找不到答案。

If you just copy and paste the images into the folder of your project using windows, it is unlikely that the build is gonna predict that you need this image as a part of your process. 如果仅使用Windows将图像复制并粘贴到项目的文件夹中,则该构建不太可能会预测您需要此图像作为过程的一部分。

You need to add an image item to your project using Visual Studio and set its properties ( Copy To Ouput Directory => Always ). 您需要使用Visual Studio将图像项添加到项目中并设置其属性( Copy To Ouput Directory => Always )。

Or the best approach is go to your Project Settings > Resources and add an image resource from existing file there. 或最好的方法是转到“项目设置”>“资源”,然后从现有文件中添加图像资源。 And then use it inside your code using Properties.Resources.YouImageName you through the designer. 然后通过设计器使用Properties.Resources.YouImageName在代码中使用它。

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

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