Einzelnen Beitrag anzeigen

Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#15

Re: [C#] Fragen zu automatisch generiertem Code

  Alt 24. Jul 2004, 19:21
OK, hier der gesamte Code:
Code:
namespace Project1
{
   /// <summary>
   /// Summary description for WinForm.
   /// </summary>
   public class WinForm : System.Windows.Forms.Form
   {
      /// <summary>
      /// Required designer variable.
      /// </summary>
      private System.ComponentModel.Container components = null;
      private System.Windows.Forms.Button btnClose;
      private System.Windows.Forms.Button btnAbout;
      private System.Windows.Forms.Label lblBanner;

      public WinForm()
      {
         //
         // Required for Windows Form Designer support
         //
         InitializeComponent();
         //
         // TODO: Add any constructor code after InitializeComponent call
         //
      }

      /// <summary>
      /// Clean up any resources being used.
      /// </summary>
      protected override void Dispose (bool disposing)
      {
         if (disposing)
         {
            if (components != null)
            {
               components.Dispose();
            }
         }
         base.Dispose(disposing);
      }

      #region Windows Form Designer generated code
      /// <summary>
      /// Required method for Designer support - do not modify
      /// the contents of this method with the code editor.
      /// </summary>
      private void InitializeComponent()
      {
         this.btnClose = new System.Windows.Forms.Button();
         this.lblBanner = new System.Windows.Forms.Label();
         this.btnAbout = new System.Windows.Forms.Button();
         this.SuspendLayout();
         // 
         // btnClose
         // 
         this.btnClose.Location = new System.Drawing.Point(208, 144);
         this.btnClose.Name = "btnClose";
         this.btnClose.TabIndex = 0;
         this.btnClose.Text = "&Schließen";
         this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
         // 
         // lblBanner
         // 
         this.lblBanner.BackColor = System.Drawing.Color.White;
         this.lblBanner.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
         this.lblBanner.Location = new System.Drawing.Point(0, 0);
         this.lblBanner.Name = "lblBanner";
         this.lblBanner.Size = new System.Drawing.Size(296, 72);
         this.lblBanner.TabIndex = 2;
         this.lblBanner.Text = "lblBanner";
         this.lblBanner.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
         // 
         // btnAbout
         // 
         this.btnAbout.Location = new System.Drawing.Point(232, 8);
         this.btnAbout.Name = "btnAbout";
         this.btnAbout.Size = new System.Drawing.Size(48, 23);
         this.btnAbout.TabIndex = 3;
         this.btnAbout.Text = "&Info";
         this.btnAbout.Click += new System.EventHandler(this.btnAbout_Click);
         // 
         // WinForm
         // 
         this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
         this.ClientSize = new System.Drawing.Size(292, 175);
         this.Controls.Add(this.btnAbout);
         this.Controls.Add(this.lblBanner);
         this.Controls.Add(this.btnClose);
         this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
         this.MaximizeBox = false;
         this.Name = "WinForm";
         this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
         this.Text = "Foo";
         this.Load += new System.EventHandler(this.WinForm_Load);
         this.ResumeLayout(false);
      }
      #endregion


   const String APPNAME = "Hello";
   const String VER = "1.0";
   const String INFO_TEXT = APPNAME + " " + VER+"\nCopyright (c) 2004 Michael Puff\n\nhttp://www.luckie-online.de";

      /// <summary>
      /// The main entry point for the application.
      /// </summary>
      [STAThread]
      static void Main()
      {
         Application.Run(new WinForm());
      }
      
      private void btnClose_Click(object sender, System.EventArgs e)
      {
         Application.Exit();
      }
      
      private void WinForm_Load(object sender, System.EventArgs e)
      {
        this.Text = APPNAME;
          lblBanner.Text = APPNAME;
      }
      
      private void btnAbout_Click(object sender, System.EventArgs e)
      {
         MessageBox.Show(INFO_TEXT, APPNAME, MessageBoxButtons.OK, MessageBoxIcon.Information);
      }
   }
}
Wie man sieht gehört die letzte schließende Klammer zu ersten öffnenden Klammer. Und somit liegen die Methoden von WinForm eindeutig im Namespace von Project1.

[edit=fkerber]Neu gespeichert wg. Code-Highlighting. Mfg, fkerber[/edit]
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat