直下にある基本クラスがないことがわかりました:
Textbox, Label and Button
これらの定義は次のとおりです。
public class TextBox : TextBoxBase
public abstract class TextBoxBase : Control
public class Button : ButtonBase, IButtonControl
public abstract class ButtonBase : Control
public class Label : Control
in .net #region Assembly System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 // C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System .Windows.Forms.dll
更新ボタンをオーバーライドし、すべてのコントロールにいくつかのカスタム プロパティとカスタム イベント ハンドラーを追加する必要がありました。したがって、カスタム コントロールを作成することにしました。しかし、それは、すべてのクラスが Control から直接拡張されているわけではないことに気付く前のことです。インターフェイスを使用して、メソッド/プロパティがコントラクトに含まれていることを少なくとも強制できることはわかっていますが、インターフェイスを拡張するたびにではなく、これらの「カスタム」メソッドのコードを記述できるようにしたいと考えています。
別の方法はありますか?
これはカスタム Control クラスであり、継承したい機能です。ファンタジーは、私が次のようなことをするということです:
public class TextBox : Sgctrl (もちろん、以下に示すように私の方法では不可能なため、ファンタジー)
public class SGctrl : Control
{
public String MySystem_SourceField { get; set; }
protected Core ctrlCore { get; set; }
protected MyForm.Forms.Location.FormLoc callingForm;
// the delegate
public delegate void Published_DELEGATE_TYPE_MySysConnectedControlRefresh(object aSGctrl, SGRefreshHandler sgr);
// This event instance of the delegate provides a hook for .NET as it makes it show up in the properties->events
// and by doubleclicking it allows other specific (textbox/label) visibility;enabled properties to be set
//
public event Published_DELEGATE_TYPE_MySysConnectedControlRefresh MySysConnectedControlRefresh_handler;
//protected virtual void OnMySysSGcontrolRefresh(SGRefreshHandler e)
protected virtual void OnMySysSGcontrolRefresh(SGRefreshHandler e)
{
if (MySysConnectedControlRefresh_handler != null)
//signature SGctrl , eventhandler object
{ MySysConnectedControlRefresh_handler(this, e); }
}
//public SGctrl(bool refreshable,Form SGcallingForm)
public SGctrl()
{
}
// will do it in the refresh method
public override void Refresh()
{
base.Refresh();
// if calling from and core reference are not yet initialized do so
if (this.callingForm == null)
this.callingForm = (MyForm.Forms.Location.FormLoc)this.TopLevelControl;
if (this.ctrlCore == null)
this.ctrlCore = this.callingForm.getCoreRef();
// pass to suscriber
//core.getField("cllabloc1");
//sgctrl.Text = sgctrl.core.getField(sgctrl.MySystem_SourceField) // get MySys data
if (this.GetType()==typeof(TextBox)) // if need to know type of control
{ }
this.Text=this.ctrlCore.getField(this.MySystem_SourceField);
SGRefreshHandler SGRefrshrobj = new SGRefreshHandler(this);
OnMySysSGcontrolRefresh(SGRefrshrobj);
}
}