Click here to Skip to main content
15,891,022 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have a tabcontrol with 8 tabpages in a project and the problem is that there is only one file containing all of the members (methods, events, properties) for all the controls on the different tabpages. it is very big, almost 6000 lines of code. Is there a way that I can create different code files so that the code for each tabpage is in a different file?

This is for a winform app.
Posted
Updated 8-Sep-10 7:20am
v3

Hi,

Are you working with .net?! If so you can try partial(in c#) class. ( I think it should be the same in vb.net too)
 
Share this answer
 
Comments
Member 4711180 8-Sep-10 13:26pm    
Yes I'm working in .net
Member 4711180 8-Sep-10 13:27pm    
I'm not sure how that would work though. Is it possible to add the class at design time?
aidin Tajadod 8-Sep-10 14:09pm    
If you are working with Visual studion 2005 or later, then by default it seperates your code from your design in two files and if you see the design file youclassname.design.cs (in c#) you can see partial keywork in the first of the class declaration. you can add another file and use partial keword and have some codes there for your main class but I am not sure if Designer knows that file too! for exmaple :
public class Myclass
{
int x;
}
partial class Myclass
{
public void initial()
{
x=1;
}
}
Dalek Dave 8-Sep-10 15:55pm    
Good call.
Member 4711180 8-Sep-10 17:49pm    
WHat I would like to do is be able to add a custom tabpag at design and double click that page to access its members (methods, events, properties). But I dont think that's possible
Try creating a user control for certain parts. It's really easy if you're using Visual Studio 2005 and above. First, open the large form, select the contents of a the page, right click and copy. Second, create a new item, choose UserControl and and paste the contents. Third, transfer all the events for the pasted controls. Fourth, BUILD the project (no need to run). Fifth, go back to the form and enter design view. You should have a new control in your toolbox (the one with the blue cog icon). Drag that to your page.
 
Share this answer
 
Comments
Johnny J. 17-Sep-10 8:24am    
I second this suggestion...
I think it is better to go Moduler. Create small Utility classes, may be a static class can be handy.

You can also break apart your file with 6000 lines into smaller partial classes, but I think it is not good to handle a large class with 6000 lines. Divide each part into its own class and use it directly from the code when required.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900