运行时从字符串设置 属性

Runtime set property from a string

我在数据库中存储了一个字符串 'GridColumn1.Caption = "XYZ"'

有没有办法在运行时(在 windows 表单加载时)执行此代码以在 vb.net 或 c# 中将 GridColumn1 的标题 属性 设置为 "XYZ"?

我想在加载表单时从数据库读取它并设置标题和文本。

提前致谢。

是的,你可以!您可以使用 Microsoft.CSharp.CSharpCodeProvider 在运行时编译和执行代码。

可以在 this question 的答案中找到更多信息。