![](/img/trans.png)
[英]Getting Text property of dynamic created ASPxTextBox with reflection c#
[英]how to set text property assigned to the control created dynamically usiong reflection?-C#
如何设置分配给动态创建的控件的文本属性?
Type type = Type.GetType(strFullName);
object instance = Activator.CreateInstance(type);
ctrlTemp = (Control)instance;
ctrlTemp.ID = "Hello";
ctrlTemp.Text???
Panel1.Controls.Add(ctrlTemp);
PropertyInfo.SetValue方法 :设置属性的值以及索引属性的可选索引值。
PropertyInfo piInstance =
typeof(Example).GetProperty("InstanceProperty");
piInstance.SetValue(exam, 37, null);
if (ctrlTemp.GetType() == typeof(TextBox))
{
TextBox textbox = (TextBox)ctrlTemp;
ctrlTemp.Text = "Your text";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.