1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

C# - Buttonのサンプル コードべた書き(Visual Studio不使用)

Last updated at Posted at 2021-02-27

目次: C# - Windows Formsでよく使うコントロールたち (Visual Studioなし環境向け) - Qiita

画面キャプチャ

image.png

テンプレ


using System;
using System.Drawing;
using System.Windows.Forms;

class ButtonSample:Form
{
    ButtonSample()
    {
        var button = new Button(){
            Location = new Point(10, 10),
            Size = new Size(150, 25),
            Text = "push",
        };
        Controls.Add(button);

        button.Click += ButtonClick;
        // button.Click += (sender,e)=>{MessageBox.Show("clicked!");};
    }

    void ButtonClick(object sender, EventArgs e)
    {
        MessageBox.Show("clicked!");
    }

    [STAThread]
    static void Main()
    {
        Application.Run(new ButtonSample());
    }
}

参考サイト

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?