2008-10-21 9 views
7

विजुअल स्टूडियो में, जब आप अपने समाधान में एक नया विंडोज फॉर्म बनाते हैं तो दो फाइलें बनाई जाती हैं (उदाहरण के लिए यदि आप MyForm.cs, MyForm.Designer.cs और MyForm.resx भी बनाए जाते हैं)। इन दूसरी दो फ़ाइलों को समाधान एक्सप्लोरर में एक उप -्री के रूप में प्रदर्शित किया जाता है।क्या मैं एक ऐसी फाइल बना सकता हूं जो Visual Studio में designer.cs फ़ाइल के बगल में बैठे हो?

क्या Windows फॉर्म क्लास के लिए उप-पेड़ या समूह में फ़ाइलों को जोड़ने का कोई तरीका है?

उत्तर

14

संपादन मोड में खुला .csproj, फ़ाइल आप एक दूसरे के नीचे होना चाहते हैं के लिए देखो, और DependentUpon तत्व जोड़, इस तरह:

<Compile Include="AlertDialog.xaml.cs"> 
    <DependentUpon>AlertDialog.xaml</DependentUpon> 
</Compile> 
+0

फ़ाइलनेटिंग एक्सटेंशन स्वचालित रूप से ऐसा कर सकता है: https://marketplace.visualstudio.com/items?itemName=MadsKristensen.FileNesting – John

6

आपको सीस्पोज़ को सीधे संपादित करने की आवश्यकता है। एक DependentUpon टैग है जिसे आपको उस फ़ाइल के बाल टैग के रूप में जोड़ना है जिसे आप MyForm.cs के अंतर्गत रखना चाहते हैं।

उदाहरण:

<Compile Include="MyForm.MyCoolSubFile.cs"> 
    <DependentUpon>MyForm.cs</DependentUpon> 
</Compile> 
4

हाँ, लेकिन यह एक परेशानी का थोड़ा सा है - मूल रूप से आपको प्रोजेक्ट फ़ाइल को हाथ से संपादित करने की आवश्यकता है।

यहाँ एक परियोजना से एक उदाहरण है कि मार्क Gravell और मैं दोनों काम पर:

<Compile Include="Linq\Extensions\DataProducerExt.cs" /> 
<Compile Include="Linq\Extensions\DataProducerExt.SingleReturn.cs"> 
    <DependentUpon>DataProducerExt.cs</DependentUpon> 
</Compile> 
<Compile Include="Linq\Extensions\DataProducerExt.Grouping.cs"> 
    <DependentUpon>DataProducerExt.cs</DependentUpon> 
</Compile> 
<Compile Include="Linq\Extensions\DataProducerExt.Pipeline.cs"> 
    <DependentUpon>DataProducerExt.cs</DependentUpon> 
</Compile> 
<Compile Include="Linq\Extensions\DataProducerExt.Conversion.cs"> 
    <DependentUpon>DataProducerExt.cs</DependentUpon> 
</Compile> 
<Compile Include="Linq\Extensions\DataProducerExt.Math.cs"> 
    <DependentUpon>DataProducerExt.cs</DependentUpon> 
</Compile> 

नोट तत्व निर्भरता में से प्रत्येक में "DependentUpon"। यह माता-पिता के रूप में DataProducerExt.cs के साथ, VS में उचित रूप से प्रदर्शित करता है।

संबंधित मुद्दे