For example, you may need a grid with some standard design to repeat dynamically. You can use the below code to create the clone of the required controls or objects.
private object CloneControls(object o)
{
Type type = o.GetType();
PropertyInfo[] properties = type.GetProperties();
Object retObject = type.InvokeMember("", System.Reflection.BindingFlags.CreateInstance, null, o, null);
foreach (PropertyInfo propertyInfo in properties)
{
return retObject;
}
PropertyInfo[] properties = type.GetProperties();
Object retObject = type.InvokeMember("", System.Reflection.BindingFlags.CreateInstance, null, o, null);
foreach (PropertyInfo propertyInfo in properties)
{
if (propertyInfo.CanWrite)
{
}{
propertyInfo.SetValue(retObject, propertyInfo.GetValue(o, null), null);
}return retObject;
No comments:
Post a Comment