将表单从一个项目复制到另一个项目,但资源未显示 VB.net
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25914665/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Copy form from one project to another but resources not showing VB.net
提问by Graham Jones
I have two projects that I want to use the same form in. In VB6 this was easy as I had a Common Folder for Common Code and could just add it.
我有两个项目,我想在其中使用相同的表单。在 VB6 中,这很容易,因为我有一个用于公共代码的公共文件夹,只需添加它即可。
I have copied the 3 files:
我已经复制了 3 个文件:
form.vb
表格.vb
form.designer.vb
表单设计器.vb
form.resx
表单.resx
I then added an existing item and selected the form.designer.vb Everything looks fine, but the 2 pictures I had are not showing even though the picture boxes are. I can expand the arrow under form.vband see form.designer.vband form.resxIf I click on the resource file I can see my two pictures.
然后我添加了一个现有项目并选择了 form.designer.vb 一切看起来都很好,但是即使图片框显示,我拥有的 2 张图片也没有显示。我可以展开form.vb下的箭头,看到form.designer.vb和form.resx如果我点击资源文件我可以看到我的两张图片。
Why have the pictures not shown in there boxes and how do I get them back in, without importing the files again?
为什么图片没有显示在那里的框中,我如何在不再次导入文件的情况下将它们放回原处?
回答by Graham Jones
I've found the Answer, or rather my dad showed me.
我找到了答案,或者更确切地说是我爸爸给我看的。
All I was adding was the form.designer.vbfile, my dad showed me that if I add an existing item and select all three files during the add, it brings the form in correctly with all the resources showing in the correct place.
我添加的只是form.designer.vb文件,我爸爸告诉我,如果我添加一个现有项目并在添加过程中选择所有三个文件,它会正确地将表单引入,所有资源都显示在正确的位置。
So I removed the form I'd added, and I added it again selecting all three forms and it now works fine and all the graphics are in the correct place.
所以我删除了我添加的表单,然后我再次添加了它,选择了所有三个表单,现在它工作正常,所有图形都在正确的位置。
Thanks Dad :-)
感谢爸爸 :-)
回答by Joel Coehoorn
You should put this form in a third project (a class library project), and include the new third project in the Visual Studio solution with the other two.
您应该将此表单放在第三个项目(类库项目)中,并将新的第三个项目与其他两个项目一起包含在 Visual Studio 解决方案中。

