All pastes #228975 Raw Edit

Miscellany

public text v1 · immutable
#228975 ·published 2006-10-30 10:36 UTC
rendered paste body
using System;
using System.Windows.Forms;

namespace beep_button
{
    static class main
    {
        static object frm;

        static void Main()
        {
            frm = new my_form();
        }
    }

    public class my_form : Form
    {
        public Form frmMain;
        public Button btnOk;

        public my_form()
        {
            // Build the form
            frmMain = new Form();
            frmMain.Width = 300;
            frmMain.Height = 300;

            // Build the button
            btnOk           = new Button();
            btnOk.Parent    = frmMain;
            btnOk.Text      = "Beep!";
            btnOk.Width     = 100;
            btnOk.Height    = 100;
            btnOk.Top       = ( ( frmMain.Height / 2 ) - ( btnOk.Height / 2 ) );
            btnOk.Left      = ( ( frmMain.Width / 2 ) - ( btnOk.Width / 2 ) );
            btnOk.Click     += new EventHandler(btnOk_click);

            Application.Run(frmMain);
        }

        public void btnOk_click(object sender, EventArgs e)
        {
            System.Console.Beep();
        }
    }
}