Eddie SheffieldAs the first discovery outside of Microsoft Form Designer Really amazing. .
A few years later Find some information about Form Designer, although not many or comprehensive, but after all there are still some. My materials are:
1 ,《 Dissecting a C # Application Inside sharpdevelop Chinese version 16 Chapter Special lecture Form Designer;
2 , Windowsforms.net A small example downloaded from Sharpdevelop Get the idea;
3 , Winres This tool, along Vs2005/. Net framework2.0 A resource localization tool. You can decompile it to see its source code.
Comparison 1 , 2 And 3, I found that both of them are implemented. Form Designer But the design logic is quite different. , Apparently Winres The method should be concise. The reason is: . NET 2.0 The function of the designer is enhanced and the calling method of the designer is simplified. Due to time constraints, write a fully functional Form The designer may be difficult. What I want to do is to perform some tests and write a File Based on. NET 2.0. Form The basic method of the designer.
I want to first write a small example that does not have any function but can see the designer style to test. The design functions will be added later, such as adding and deleting controls, setting properties, and saving files.
The procedure is as follows:
In Vs2005 Medium ( The version I used is RC) Create C # windowsform Solution , Add to project reference System. Design, In Form1 OfCodeAdd
Using System. componentmodel. design;
Double-clickForm,InFormOfLoadWrite the following code in the event:
Designsurface Surface = New Designsurface ();
Surface. beginload ( Typeof (Form ));
Control View = (Control) surface. view;
View. Dock = Dockstyle. Fill;
This . Controls. Add (View );
Then run the scheme. This is the simplest and useless Form Designer, but at least we can adjust the designedFormSize