Partial Classes

rbulph

Junior Contributor
Joined
Feb 17, 2003
Messages
397
How do I do partial classes? I've got a form which has a body of code which is logically a separate block, and I'd like to be able to view that block by itself. So I decided to put it into a partial class. This works OK, except that if I have it in the same module as the form, the form's designer won't show. If I have it in a separate module the form's designer will show but if I double click on that module vb creates an extra designer (a basic form) and inserts initialization code in my module for it. And then I can't open the designer for the form again. Hmm.
 
rbulph said:
How do I do partial classes? I've got a form which has a body of code which is logically a separate block, and I'd like to be able to view that block by itself. So I decided to put it into a partial class. This works OK, except that if I have it in the same module as the form, the form's designer won't show. If I have it in a separate module the form's designer will show but if I double click on that module vb creates an extra designer (a basic form) and inserts initialization code in my module for it. And then I can't open the designer for the form again. Hmm.

The main purpose of partial classes is to provide a way of having both auto-generated and manually written code in one class. Therefore its a merely a workaround for tools (in our case - for Visual Studio) and developers should avoid using partical classes for organizing their source code. If you feel that some part of code does not belong here and logically should be separated from the "main" class - consider making a new class from it.

Unfortunately forms designer is not the best part (not to say more :cool: ) of visual studio and so far as I remember it never was :(
 
Last edited:
Igor Sukhov said:
The main purpose of partial classes is to provide a way of having both auto-generated and manually written code in one class. Therefore its a merely a workaround for tools (in our case - for Visual Studio) and developers should avoid using partical classes for organizing their source code. If you feel that some part of code does not belong here and logically should be separated from the "main" class - consider making a new class from it.

Unfortunately forms designer is not the best part (not to say more :cool: ) of visual studio and so far as I remember it never was :(
OK, thanks. The code is more of a subsection of the form's code than something logically separate, so I was hoping just to be able to display it by itself so that I could review it without being distracted by the other code of the form. But I could think of a way to move it out, so I guess that's what I should do.
 
Back
Top