2017-09-15 129 views
0

我要添加這樣的資源文件 enter image description here資源文件C#

,但是當我添加的資源文件的項目,它好像enter image description here

我怎麼可以添加像第一?

+0

這似乎顯示不同,因爲在第一張圖片,文件顯示在'OutOfDepartement.cs'形式水平和第二張圖片,我想,在項目層面。 –

回答

1

當您向項目添加新窗體時,Visual Studio會自動完成此操作。底層機制很簡單,但如果您想手動執行此操作,則必須在文本編輯器中編輯csproj文件,並將一些xml工件添加到新添加的資源文件節點。

有一個名爲DependentUpon的xml屬性,您可以在csproj中設置,然後Visual Studio會在您設置的父窗體下顯示該節點。

這裏是從項目文件中的一個這樣的條目相關的部分(我用VB項目在這裏,但CS應該是相似的):

<Compile Include="My Project\Resources.Designer.vb"> 
    <AutoGen>True</AutoGen> 
    <DesignTime>True</DesignTime> 
    <DependentUpon>Resources.resx</DependentUpon> 
</Compile> 

DependentUpon線就是在鏈接Resources.Designer.vbResources.resx解決方案瀏覽器。

+0

有一個方便的[VS擴展](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.FileNesting)。 – Sinatr

0

我加入像另一個文件

<EmbeddedResource Include="OutOfDepartment.tr-TR.resx"> 
     <DependentUpon>OutOfDepartment.cs</DependentUpon> 
    </EmbeddedResource> 

但似乎這個enter image description here

+0

查看'csproj'中條目的順序是否有所不同。另外請確保通過VS正常添加這兩個文件,然後手動編輯它。 – dotNET

+0

完成!我添加了新的資源文件並寫入名爲OutOfDepartment.tr-TR.resx並自動添加!非常感謝! – Tubaa