Control Code Generation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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...
 
Back
Top