Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C# by Dan ( 18 years ago )
using System;
using System.Windows.Forms;
using System.Drawing;



public class MainApp : System.Windows.Forms.Form {

   private Button   info  = new Button();
   private Button   quit  = new Button();
   private CheckBox check = new CheckBox();
   private ListBox  list  = new ListBox();


   // Entry Point, ruft Hauptprogramm auf
   public static int Main(string[] args) {
      Application.Run(new MainApp());
      return 0;
   }

   // Hauptprogramm
   public MainApp() {

      // Fenster initialisieren
      this.Text            = "C# Test Window";
      this.ClientSize      = new Size(230,260);
      this.StartPosition   = FormStartPosition.CenterScreen;
      this.FormBorderStyle = FormBorderStyle.FixedDialog;
      this.MaximizeBox     = false;
      this.MinimizeBox     = false;

      // Button "info" initialisieren
      info.Location        = new Point(10,10);
      info.Size            = new Size(100,20);
      info.Text            = "INFO!";
      info.Click          += new System.EventHandler(info_Click);

      // Button "quit" initialisieren
      quit.Location        = new Point(120,10);
      quit.Size            = new Size(100,20);
      quit.Text            = "Quit";
      quit.Click          += new System.EventHandler(quit_Click);

      // CheckBox initialisieren
      check.Location       = new Point(10,40);
      check.Size           = new Size(100,20);
      check.Text           = "CheckBox";
      check.Click         += new System.EventHandler(check_Click);
      
      // ListBox initialisieren
      list.Location        = new Point(10,70);
      list.Size            = new Size(210,170);
      list.Click          += new System.EventHandler(list_Click);

      // ListBox fuellen
      for (int i=1; i<=200; i++) {
         list.Items.Add("ListBox Zeile "+i.ToString());
      }


      // Controls zum Fenster hinzufuegen
      this.Controls.Add(info);
      this.Controls.Add(quit);
      this.Controls.Add(list);
      this.Controls.Add(check);

   }


   // Event-Handler fuer Button "quit"
   private void quit_Click(object sender, EventArgs evArgs) {
      base.Dispose(); // exit
   }

   // Event-Handler fuer Button "info"
   private void info_Click(object sender, EventArgs evArgs) {
      MessageBox.Show("C# window example by Danilo",
                      "INFO",
                      MessageBoxButtons.OK,
                      MessageBoxIcon.Information);
   }

   // Event-Handler fuer CheckBox
   private void check_Click(object sender, EventArgs evArgs) {
      MessageBox.Show("Checkbox Status: "+check.Checked.ToString(),
                      "INFO",
                      MessageBoxButtons.OK,
                      MessageBoxIcon.Information);
   }

   // Event-Handler fuer ListBox
   private void list_Click(object sender, EventArgs evArgs) {
      MessageBox.Show("Ausgew&iuml;&iquest;&frac12;lt: "+list.SelectedItem.ToString(),
                      "INFO",
                      MessageBoxButtons.OK,
                      MessageBoxIcon.Information);
   }

}

 

Revise this Paste

Your Name: Code Language: