GMMorris Posted April 3, 2004 Posted April 3, 2004 Hi, I have 2 controls I developed - lets call them CContanor and CItem (They aren't called that, but this makes it simpler). CContanor contains many instances of CItem, and I've made a designer to assist in adding these CItems to CContanoir at designtime. The problem is that when I add CItems to CContanor using the designer, it generates code which isn't suitable for my needs. It creates a new instance (In the "private void InitializeComponent()" method) of each CItem, sets several properties such as name and size, and then adds the CItems to CContaner useing - CContaner.Controls.Add(CItem); which is not good - because I need these controls to be added using a custom method - CContaner.AddMyItem(CItem); So it dosn't work properly. My two question are: 1)How do I change the code generation so that it uses : CContaner.AddMyItem(CItem); instead of- CContaner.Controls.Add(CItem); 2)How do I control the properties set in the InitializeComponent() of each CItem? Quote Latly it would seem as though I'm don't abnegate from anything... except women. :( :)
AlexCode Posted April 4, 2004 Posted April 4, 2004 To assure that a property is serialized use this attribute on the property: <System.ComponentModel.DesignerSerializationVisibility(ComponentModel.DesignerSerializationVisibility.Content)> The Controls.Add problem I advise you to use the ControlAdded event on your container control instead of creating a new way of adding controls... ;) Alex :p Quote Software bugs are impossible to detect by anybody except the end user.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.