How to split <form1.cs> into multiple files?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have a form that has many controls and related actions. My <form.cs> file has crossed 13,500 lines of code. It takes quite a long to load the form or .cs file. I want to divide into small portions. I am thinking of dividing it module-wise. I want to write the event handling functions of a specific module in another file. Is that possible? Can we write the event handler in another file?

Is there any better way to handle this situation?

Thanks
 
I think the only way is using partial classes, a feature that will be
available in the next release of C#.
In the meantime, remember not to include application logic in event
handlers.
 
for example you can split your class in a base class(form1_base), which implements only the UI Controls. the next class(form1_eh), which is derived from the form1_base, implements the eventhandler. the next class, which is derived from the form1_eh, implements other function, and so on
 
Back
Top