简体   繁体   English

设置自定义控件属性

[英]Setting custom control properties

I though it would be very simple but I can not get it today. 我虽然很简单,但我今天无法得到它。

I have a user control, with a grid control contained in it. 我有一个用户控件,其中包含一个网格控件。

public Unit Width
{
    get
    {
        return CustomerGrid.Width;
    }
    set
    {
        CustomerGrid.Width = value;

    }
}

I expose the width property and when I set it in the designer it works at run-time but not design time. 我公开了width属性,当我在设计器中设置它时,它在运行时工作但不是设计时。

What class do I inherit from or method to override to get my controls to function at design time. 我将继承什么类或重写方法以使我的控件在设计时运行。

Note I tried to inherit from WebControl but got the message 注意我试图从WebControl继承但得到了消息

Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class 

I understand you're talking about user controls (ascx) and not about custom controls (no ascx). 我知道你在谈论用户控件(ascx)而不是自定义控件(没有ascx)。 If this is the case, you should inherits from UserControl and you would have the property available on design time without any other addition. 如果是这种情况,您应该从UserControl继承,并且您可以在设计时使用该属性而无需任何其他添加。

In case you're talink about custom controls, here you have a good article about adding design time support to custom controls 如果你对自定义控件有所了解,那么你有一篇关于为自定义控件添加设计时支持的好文章

http://msdn.microsoft.com/en-us/library/aa478960.aspx http://msdn.microsoft.com/en-us/library/aa478960.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM