Assigning control properties from another instance of the same type

  • Thread starter Thread starter nicolasr
  • Start date Start date
N

nicolasr

Hi,

is it possible to assign all properties of a control given another
control of the same type? From Borland Delphi/C++Builder
I am used to the Assign method which copies all properties
at once like this:

(pseudo code)
Button1 = new Button;
Button1.Width = 20;
Button1.Height = 20;

Button2.Assign(Button1);

Now Button2 has the same dimensions as Button1.

Is anything similar available in the dotnet framework?

thanks,
Nick
 
nicolasr said:
is it possible to assign all properties of a control given another
control of the same type? From Borland Delphi/C++Builder
I am used to the Assign method which copies all properties
at once like this:

(pseudo code)
Button1 = new Button;
Button1.Width = 20;
Button1.Height = 20;

Button2.Assign(Button1);

Now Button2 has the same dimensions as Button1.

Is anything similar available in the dotnet framework?

There is no built-in method available for this purpose. You can derive
a class from button and extend it with an 'Assign' method with your
implementation. Have a look for reflection for copying the property values.
 
Back
Top