|
-
October 9th, 2004, 07:54 PM
#1
Custom code generation
I am creating my own component, which is like TabControl.
I created my own collecation class (PageCollection) and added the property of this type to component class.
I also added additional properties, ActivePage and ActivePageIndex.
Everything goes OK, but the order of statements of code inserted by designer is not what I really need.
Code is generated in the following order:
ActivePage, ActivePageIndex, ..., Pages
But actually it must be as follows:
Pages, ActivePage, ActivePageIndex
The properties in InitializeComponent function appears in alphabetical order, how to override that order???
-
October 10th, 2004, 05:03 PM
#2
Re: Custom code generation
Edit the InitializeComponent method and set the priorities you want.
Simple eh ?
If you open the form in the designer then it may re-arrange the order again, but most of the time it leaves the code alone so don't worry.
Darwen.
-
October 11th, 2004, 05:33 AM
#3
Re: Custom code generation
Reptile,
if you're creating a component for other people to use the following should be of use. Code Generation
By the sound of it the section Making Components Aware of Initialization is what you are after.
-
October 11th, 2004, 07:04 AM
#4
Re: Custom code generation
I don't want to rearrange the order of elements each time I change the design of my form. Because if the order that code designer places the elements is not suitable, and I place them in the order I need, the next time form's design changes, the order changes too.
Also I don't want to do this via code generation itself. Because the component I designed for C# and VB.NET will not be suitable for use in other .NET languages, if I don't implement them too.
The code designer places properties' initialization in alphabetical order. So one of the simplest way is to name them in order they must be placed in code.
But that's not the correctest way of that.
So what is the simpler way of doing what I need to?
Or do I really need to go through code generation?
-
October 11th, 2004, 07:34 AM
#5
Re: Custom code generation
Why is the order important? To quote the article,
the rule of thumb is to keep them modeless with respect to property sets. What that means is that users should be able to set properties in any order on an object and get the same results.
.
With respect to code generation, if it comes down to it, the article addresses this with CodeDom which is a) language independent and b) is used by the designers to generate the statements you're actually asking about!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|