PC Review


Reply
Thread Tools Rate Thread

Control Code Generation

 
 
=?Utf-8?B?TWFyY28gUmVnbw==?=
Guest
Posts: n/a
 
      26th Jul 2005
Sorry for the newbie question ...

I need to programatically generate code for any control. One of my doubts
is how to identify the properties that were changed after "MyControl
myControl = new MyControl()". In other words, if the user coded

myControl.Location = new Point(10, 10);

by programatically analysing myControl properties, I need to be able to
detect that the Location property was changed, so I will be able to
generate the following line of code:

myControl.Name + ".Location = new Point(" +
myControl.Location.X.ToString() + ", " + myControl.Location.Y.ToString() +
");\r\n";

I need to do this for all the properties changed.
Thanks for any help.

_____
Marco
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Q2Ft?=
Guest
Posts: n/a
 
      27th Jul 2005
Not sure if this is the answer that you are looking for, but if you are
writing myControl then you can capture that the property has changed in the
set part of the property declaration:

public Point Location
{
set
{
_location = value;
// add the string to some ArrayList or something here
}
}

Or alternatively, you could have the class raise an event when each property
is modified, which could include the name of the property and the new value,
and the code in which you are creating the myControl could subscribe to it...

"Marco Rego" wrote:

> Sorry for the newbie question ...
>
> I need to programatically generate code for any control. One of my doubts
> is how to identify the properties that were changed after "MyControl
> myControl = new MyControl()". In other words, if the user coded
>
> myControl.Location = new Point(10, 10);
>
> by programatically analysing myControl properties, I need to be able to
> detect that the Location property was changed, so I will be able to
> generate the following line of code:
>
> myControl.Name + ".Location = new Point(" +
> myControl.Location.X.ToString() + ", " + myControl.Location.Y.ToString() +
> ");\r\n";
>
> I need to do this for all the properties changed.
> Thanks for any help.
>
> _____
> Marco

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable code generation on double-click of control Dan Reber Microsoft Dot NET Framework Forms 1 26th Aug 2007 11:34 PM
Disable code generation on double-click of control Dan Reber Microsoft C# .NET 1 22nd Aug 2007 03:31 PM
Control Code Generation =?Utf-8?B?TWFyY28gUmVnbw==?= Microsoft Dot NET Framework Forms 0 26th Jul 2005 05:55 PM
Auto code generation overrides my control in base class mirek Microsoft ASP .NET 2 16th Feb 2004 04:21 PM
Wizard for creating a new user control is DIFFERENT on code generation than Forms, inconsistend by a lazy wizard dev news.microsoft.com Microsoft Dot NET Framework Forms 4 2nd Nov 2003 07:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:30 AM.