开发者

how to set text property assigned to the control created dynamically usiong reflection?-C#

how to set text property assigned to the control created dynamically usiong reflection?

Type type = Type.GetType(strFullName);

    object instance = Activator.CreateInstance(type);

    ctrlTemp = (Control)instance;

    ctrlTemp.ID = "Hell开发者_运维技巧o";
    ctrlTemp.Text???
    Panel1.Controls.Add(ctrlTemp);


PropertyInfo.SetValue Method : Sets the value of the property with optional index values for index properties.

PropertyInfo piInstance = 
            typeof(Example).GetProperty("InstanceProperty");
        piInstance.SetValue(exam, 37, null);


if (ctrlTemp.GetType() == typeof(TextBox))
{
    TextBox textbox = (TextBox)ctrlTemp;
    ctrlTemp.Text = "Your text";
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜