Exemplo n.º 1
0
        public FormOpg0()
        {
            // Laver instans af klasserne
            lblHello  = new Label();
            btnHello  = new Button();
            nbtnHello = new NumberButton(1);

            // initialisering
            Controls.Add(lblHello);
            Controls.Add(btnHello);
            Controls.Add(nbtnHello);

            lblHello.Location = new Point(12, 9);
            lblHello.Text     = "Hello world";


            // x starter fra toppen og y starter fra venstre i point
            btnHello.Location = new Point(32, 36);
            btnHello.Text     = "Tryk";
            // Click er et event og der tilføjes flere handlers
            btnHello.Click       += BtnAdd_Click;
            btnHello.DoubleClick += BtnAdd_Click;

            nbtnHello.Location = new Point(100, 100);
        }
Exemplo n.º 2
0
 private void SetupNumberButtons()
 {
     NumberButton[] buttons = new NumberButton[10];
     for (int buttonIndex = 0; buttonIndex < 9; buttonIndex++) // initialize 1-9
     {
         int          xPosition    = ((buttonIndex % 3) * 30);
         int          yPosition    = (2 - ((buttonIndex - (buttonIndex % 3)) / 3)) * 30;
         NumberButton numberButton = new NumberButton(buttonIndex + 1);
         numberButton.Location = new Point(xPosition, yPosition);
         numberButton.Size     = new Size(25, 25);
         buttons[buttonIndex]  = numberButton;
     }
     buttons[9]      = new NumberButton(0, new Point(0, 90)); // initialize 0
     buttons[9].Size = new Size(3 * 25, 25);
     this.SuspendLayout();
     foreach (NumberButton button in buttons)
     {
         this.Controls.Add(button);
         button.NumberClick += ButtonNumberClick;
     }
     this.ResumeLayout();
 }