Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Accesing constructor';s的基类属性_C#_Base_Componentone - Fatal编程技术网

C# Accesing constructor';s的基类属性

C# Accesing constructor';s的基类属性,c#,base,componentone,C#,Base,Componentone,为了在C1InputPanel中使用C1DropDownControl,我需要定义一个继承自InputControlHost类的类,然后调用所需控件的构造函数,如下所示: public class InputC1DropDownControl : InputControlHost { public InputC1DropDownControl() : base(new C1DropDownControl()) { } } 通过这样做,我可以看到C1In

为了在C1InputPanel中使用C1DropDownControl,我需要定义一个继承自InputControlHost类的类,然后调用所需控件的构造函数,如下所示:

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类中