Assigning control properties from another instance of the same type

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
 
H

Herfried K. Wagner [MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top