C# Accesing constructor';s的基类属性
为了在C1InputPanel中使用C1DropDownControl,我需要定义一个继承自InputControlHost类的类,然后调用所需控件的构造函数,如下所示:C# Accesing constructor';s的基类属性,c#,base,componentone,C#,Base,Componentone,为了在C1InputPanel中使用C1DropDownControl,我需要定义一个继承自InputControlHost类的类,然后调用所需控件的构造函数,如下所示: public class InputC1DropDownControl : InputControlHost { public InputC1DropDownControl() : base(new C1DropDownControl()) { } } 通过这样做,我可以看到C1In
public class InputC1DropDownControl : InputControlHost
{
public InputC1DropDownControl()
: base(new C1DropDownControl())
{
}
}
通过这样做,我可以看到C1InputPanel中的C1DropDownControl(它是一种特殊的组合框),但我无法访问它的所有属性。因此,我的问题是:如何从InputC1DropDownControl对象(显然是从其他类继承的)访问C1DropDownControl属性?您只需使用
控件
属性,然后强制转换:
var control = (C1DropDownControl) controlHost.Control;
// Use the various properties
InputControlHost
有一个名为Control
的属性。你应该可以做一些类似的事情
C1DropDownControl hostedControl = Control as C1DropDownControl;
hostedControl.Whatever...
在InputC1DropDownControl类中