すみません教えて下さい。 自作のカレンダーコントールを作りました。 作ったといってもボタンをクリックすると あらかじめフォームに貼ったmonthCalendar1のVisible = trueにして ボタン(ボタン継承で作成)近くにmonthCalendar1を移動させて クリックにより日付を年月日別のテキストボックスセットするという内容です 以下質問内容です。 ■1 ボタンクリック時に自分自身の名前を取得したい ButtonCren_Clickはカレンダー用複数のボタンに関連づけています。 ■2 継承ボタンでのプロパティに設定した dataCntrol と SetTextNameから値を取得したいが参照方法がわかりません。 ■3 カレンダーのクリックで取得したe.Start.ToShortDateString();を SetTextNameにセットしたいのですがインスタンスに設定されていませんとエラーになります。 以上 すみませんがご教授を御願いします。 環境:windows7pro .net4.5 VS2012pro C# //==== Buttonを継承したコンポーネント public partial class ButtonEx : Button { public Component1() { InitializeComponent(); } public Component1(IContainer container) { container.Add(this); InitializeComponent(); } /// <summary> /// 呼び元のコントール名1 座標取得用 /// </summary> private string _dataCntrol = string.Empty; public string dataCntrol { get { return this._dataCntrol; } set { this._dataCntrol = value; } } /// <summary> /// 呼び元のコントール名2 セット先コントール名 /// </summary> private string _SetTextName = string.Empty; public string SetTextName { get { return this._SetTextName; } set { this._SetTextName = value; } } } //==== ボタンのクリックイベント public string TarText = string.Empty; private void ButtonCren_Click(object sender, EventArgs e) { Point mx = new Point(); Point my = new Point(); //座標取得用コントロールからの取得 //■1 BtnCren1を呼び元の名前から取得したい string work = BtnCren1.dataCntrol; TarText = BtnCren1.SetTextName; mx.X = this.Controls[work].Location.X; my.Y = this.Controls[work].Location.Y; //カレンダー表示位置の調整 //■2 tableLayoutPanel2を_dataCntrolから取得したい this.monthCalendar1.Top = my.Y + tableLayoutPanel2.Height; this.monthCalendar1.Left = mx.X + (tableLayoutPanel2.Width - monthCalendar1.Width); monthCalendar1.Visible = true; //カレンダーの表示 } //==== カレンダーのDateSelectedイベント private void monthCalendar1_DateSelected(object sender, DateRangeEventArgs e) { string work = e.Start.ToShortDateString(); //セット先コントール名から名前を設定にそれぞれ日付をセット //■3オブジェクト参照がオブジェクト インスタンスに設定されていません。 this.Controls[TarText + "Y"].Text = work.Substring(0, 4); this.Controls[TarText + "M"].Text = work.Substring(5, 2); this.Controls[TarText + "D"].Text = work.Substring(8, 2); monthCalendar1.Visible = false; }