〇 プログラムで動的にイベントハンドラを追加
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// add
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
namespace PeacePadEditor01
{
partial class PPad1_Form1 // class PPad1_Form1_RecentOpenFile
{
//---------------------------------------------------------------------------------------------
// ファイル>「最近使ったファイル」メニュー
//----------------------------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////
/// <summary>
/// helper:メニュー項目とイベントハンドラをドロップダウンへ追加
/// </summary>
/// <param name="str_file_path"></param>
private void addMenuItemsAndEventHandlerToDropDownItems() // v098.0033c
{
// DropDownItems は、サブメニュー(参照変数の短縮参照)。
ToolStripItemCollection drop_down_Items
= this.最近使ったファイルToolStripMenuItem.DropDownItems;
// メニュー項目の生成 v0.98.0045.08
ToolStripMenuItem tsmi_menu = new ToolStripMenuItem();
// サブメニュークリック時のイベントハンドラの登録(メソッド登録)
tsmi_menu.Click += new System.EventHandler( this.openFileWithToolStripMenuItem_Click );
// サブメニューとして追加登録
drop_down_Items.Add( tsmi_menu );
}
・・・
}
}