Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Custom Control Property order in InitializeComponent
 

Custom Control Property order in InitializeComponent

I'm not sure how to organise the properties in theInitializeComponent of the disigner code. I have one property that relies on two other properties, however they come after the dependant property alphabetically. I've tried using theISupportInitialize with begin Init and End init, but I'm not really sure that is the solution I'm looking for. Also how does that relate to the order of initialising the properties once they've been set?

Any help (code samples are greatly appreciated) will be welcomed :)
koenyn  Friday, February 13, 2009 1:27 PM
Validate only during and afterISupportInitialize.EndInit is called.
MSMVP VC++
Sheng Jiang 蒋晟  Monday, February 16, 2009 2:27 PM
Properties and implementations are different. You can Implement ISupportInitialize in such as way that it applies property changes made by the designer in EndInit, in any order you choose.
MSMVP VC++
Sheng Jiang 蒋晟  Friday, February 13, 2009 9:01 PM
Hi, thanks for the reply, but I'm afraid it still doesn't make sense to me. I have propertCheck,Minimum andMaximum. all type int

if I have the following scenario then I'll get an error when running a form with my control because minimum and maximum would still have the value 0 when Check is initialized.

How do I circumvent this problem usingISupportInitialize?

private int iCheck;
private int iMinimum;
private int iMaximum;

public intCheck
{
get
{
returniCheck;
}
set
{
if(value <iMinimum
|| value > iMaximum)
{
throw new ArgumentException("Check must be between Minimum and Maximum");
}
}
}

public intMinimum
{
get
{
returniMinimum;
}
set
{
iMinimum = value;
}
}

public intMaximum
{
get
{
returniMaximum;
}
set
{
iMaximum = value;
}
}
koenyn  Monday, February 16, 2009 10:18 AM
Validate only during and afterISupportInitialize.EndInit is called.
MSMVP VC++
Sheng Jiang 蒋晟  Monday, February 16, 2009 2:27 PM

Hi,

As Sheng Jiang said, we can use Implement ISupportInitialize.

Best regards,

Ling Wang


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Ling Wang  Wednesday, February 18, 2009 10:19 AM

You can use google to search for other answers

Custom Search

More Threads

• DuplicateItemsNotSupported
• Add custom user control into a form
• Designer calling the Form Load event of Base Form...
• Custom Form Designer - persisting the designer surface for later editing
• The variable 'Control Name' is either undeclared or was never assigned
• Forms Designer and GetDC() vs. GetWindowDC()
• BackgroundImageLayout missing in MdiClient control
• Validation & Tab Control
• Custom Form Desinging
• Stop them from moving a form