トップへ
C#windowsアプリ起動順序
* 2009.06.25 Thursday
* 14:45
フォームにボタンだけつけたwindowsフォームアプリの内容
F11でステップイン、デバッグをして処理の流れを理解。
ファイル名:Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace WindowsFormsApplication3
{
static class Program
{
///
/// アプリケーションのメイン エントリ ポイントです。
///
[STAThread]
static void Main() //1、ココから始まる
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());//2、new Form1()作成
}
}
}
ファイル名:Form1.Designer.cs
部品の宣言、初期化が行われる。
namespace WindowsFormsApplication3
{
partial class Form1
{
///
/// 必要なデザイナ変数です。
///
private System.ComponentModel.IContainer components = null; //3、
///
/// 使用中のリソースをすべてクリーンアップします。
///
///
マネージ リソースが破棄される場合 true、破棄されない場合は false です。
protected override void Dispose(bool disposing)・・・
#region Windows フォーム デザイナで生成されたコード
///
/// デザイナ サポートに必要なメソッドです。このメソッドの内容を
/// コード エディタで変更しないでください。
///
private void InitializeComponent()・・・・・・ //5、部品の初期化
#endregion
private System.Windows.Forms.Button button1; //部品の宣言
}
}
ファイル名:Form1.cs
イベントハンドラ、その他アプリ独自の処理を書く
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1() //4、
{
InitializeComponent(); //5
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}