A community member has associated this post with a similar question:
Retrieve the Properties of a Control without Reflection
Only moderators can edit this content.
Copy the Properties of one control to another (UPDATED with Questions)
// COPY PROPERTIES FROM ONE CONTROL TO ANOTHER WITHOUT USING REFLECTION.
// Execution Sample:Name_Test_Control_Copy.Cls_Test_Control_Copy.Fcn_Main();
//
// Goal: You want to quickly copy properties in one control to another control.
//
// -Two Controls Label1 and Label2 are Dimensioned.
// -is assigned Label1.Text = "My Label 1";
// -Label2 = Label1 is copied so that Label2 has all the Properties of Label1 assigned quickly.
// -is assigned Label2.Text = "My Label 2";
//
// Problem:Because the Controls work by reference, when checking "Label1.Text" It does not show the Initial Value but the Value Assigned to "Label2.Text".
// If I use to copy the properties one by one by Reflection, it is very slow.
namespace Name_Test_Control_Copy
{
#region Inicializacion
public static class Cls_Test_Control_Copy
{
#endregion
#region Función Test
// ------------------------------
// COPIAR LAS PROPIEDADES DE UN CONTROL EN OTRO SIN EMPLEAR REFLEXIÓN.
// ------------------------------
public static void Fcn_Main()
{ // Inicializa.
System.Windows.Forms.Label Label1 = new System.Windows.Forms.Label();
System.Windows.Forms.Label Label2 = new System.Windows.Forms.Label();
Label1.Text = "My Label 1";
// StMain. Estructura de Trabajo. Cambia Variable.
Label2 = Label1;
Label2.Text = "My Label 2";
// STOP EXECUTION WITH F9 AND CONSULT Label1.Text for "My Label 1".
{}
}
}
#endregion
}