For example I want to create a usercontrol(windows form) that contains a lable and a textbox . And I want to expose the two sub control as property , so that I can set the sub control's property in client form designer.
so the code maybe like this :
public partial class LabelTextbox : UserControl { public LabelTextbox() { InitializeComponent(); } [ Category("Appearance"), Browsable(true), Description("innerLabel") ] public DevComponents.DotNetBar.LabelX LabelPart { get { return this.labelx; } set { this.labelx = value; } } [ Category("Appearance"), Browsable(true), Description("InnerTextbox") ] public TextBox TextBoxPart { get { return this.textboxx; } set { this.textboxx = value; } } }
and then I can see it in designer , it looks like :
but when I set the usercontrol's inner label property in designer , it can't make relation code in the designer.cs . that's to say the client settings not be saved .
so how can I resolve this problem.
By the way I come from CN my English is poor . Anyone can answer me.
Decorate the properties of your child Controls with the DesignerSerializationVisibility
Attribute:
[
Category("Appearance"),
Browsable(true),
Description("innerLabel"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content) //<-- here
]
public DevComponents.DotNetBar.LabelX LabelPart {
get {
return this.labelx;
}
set {
this.labelx = value;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With