开发者

winform designer loading failed

I have wrote a winform control with vs2005.

This control is inherited from UserControl. At first, it wo开发者_Python百科rked well. But after some time, error occured when load winform designer.

The error message is below:

"NameCaption" isn't the property of type "System.Windows.Forms.UserControl".

Here is the define of NameCaption:

public string NameCaption  
{  
    get  
    {  
        return this._nameCondCaption;  
    }  
    set  
    {  
        this._nameCondCaption = value;  
        this.nameLabel.Text = value;  
    }  
}  
private string _nameCondCaption = "Name"; 

I think NameCaption is not the root cause.

How can I fix the problem?

Thanks in advanced.


I have changed the code like this:

public string NameCaption  
{  
    get  
    {  
        return this.nameLabel.Text;  
    }  
    set  
    {  
        this.nameLabel.Text = value;  
    }  
}  
private string _nameCondCaption = "Name"; 

Now it works. But I still don't understand why.


You could try making it hidden to the designer serialization using the DesignerSerializationVisibility attribute like this:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string NameCaption  
{  
    get  
    {  
        return this._nameCondCaption;  
    }  
    set  
    {  
        this._nameCondCaption = value;  
        this.nameLabel.Text = value;  
    }  
}  
private string _nameCondCaption = "Name"; 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜