HOWTO avoid that the IDE place the propertys ordered alphabetically ?

Hello,
I'm a having a issue with my custom control, because the IDE place the attributes in alphabetical order in the code (when the user place the control in a form). e...g... : if you control have three properties (Buttons, Captions y ValuesToReturn), the IDE place the attributes in this order:

mycontrol.Buttons = 2;
mycontrol.Captions = "YN";
mycontrol.ValuesToReturn ="10";

I need that the properties become placed like this:

mycontrol.ValuesToReturn ="10";
mycontrol.Captions = "YN";
mycontrol.Buttons = 2;

I need that theValuesToReturn property become the first property that the IDE set, because its value is used by theButtons property (in this property is invoked a procedure that creates the buttons), but I don't know how to do it!. Looking for in the web, I found that I need to implement the ISupportInitialization interfase, but the problems persist yet!.
Please, help me!,

[956 byte] By [CFQüeb] at [2007-12-16]
# 1
ISupportInitialize simply allows you to control batch initialization, think you'll have to implement a Custom Type Descriptor and override GetProperties() returning properties in your favorite order.
CorradoCavalli at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms Designer...
# 2
Hello Cavalli, Many thanks for your replyBig Smile. A Custom Type Descriptor and the override for the Getproperties() method only works in the PropertyGrid (I suppose) but I need that the properties order become applied into the code (automatically generate for the IDE), when the user place the control on the form. If you have a code for see an example... please share with me! 10x a lot!
CFQüeb at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms Designer...
# 4
Thank You a lot! gwapo,
The CodeDom implementations was the solution!
Regards
CFQüeb at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms Designer...
# 5
A question more:
If the property has default values (using the [DefaultValue()]), the property its not included into the CodeStatementCollection?. Where are placed the properties with default values?.
Thank You!
CFQüeb at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms Designer...
# 6

If the current value of the property is the same with the defeault value, then it will not be included in the CodeStatementCollection, because the property will not be serialized. To ensure that your property's serialization, you can include a method that starts with ShouldSerialize and ends with the name of your property, that returns a boolean value, true mean to serialize, otherwise false.

public bool ShouldSerializeMyProperty
{
return true;
}

The code above forces your property to be included in CodeStatementCollection.

Here's a detailed article (with sample) on CodeDom serialization:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/custcodegen.asp

-chris

gwapo at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms Designer...
# 7
Excelent chris!, You don't know how your help is very appreciated.
Big thanks!

RegardsBig Smile

Tabas at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms Designer...