1 usingSystem;2 usingSystem.Windows.Forms;3 4 //Version Number: 1.05[Assembly:System.Reflection.AssemblyVersion ("1.1")]6 7 //name Space8 namespaceUKE. Winform.demo9 {Ten //window class: Default Inheritance System.Windows.Forms.Form class One Public classMyForm:System.Windows.Forms.Form A { - //declaring a control instance - PrivateButton BtnLoad;//button Btload the PrivatePictureBox Pbphoto;//Picture Controls - - - //Initialize the control (in the constructor), this represents the window + PublicMyForm () - { + //Window Title A This. Text ="Hello World 1.1"; at - //button btload; -BtnLoad =NewButton (); -Btnload.text ="Loading Pictures";//button Name -Btnload.left =Ten;//button X coordinate -Btnload.top =Ten;//button Y coordinate in - //Picture Controls toPbphoto =NewPictureBox (); +Pbphoto.borderstyle =Borderstyle.fixed3d; -Pbphoto.width = This. Width/2;//Picture Control width thePbphoto.height = This. Height/2;//Picture Control Height *Pbphoto.left = ( This. Width-pbphoto.width)/2;//picture Control x-coordinate $Pbphoto.top = ( This. Height-pbphoto.height)/2;//picture Control y-coordinatePanax Notoginseng - //The Add () method adds the control in the Window collection the This. Controls.Add (BtnLoad);//button btnload Add in + This. Controls.Add (Pbphoto);//Add a picture control A the } + - $ //Program Entry $[System.stathread]//multithreaded Mode - Public Static voidMain () - { the //Enable system interface style effects - System.Windows.Forms.Application.EnableVisualStyles ();WuyiSystem.Windows.Forms.Application.Run (NewMyForm ()); the } - Wu - } About}
C # Create a winfrom window from Notepad