C# 从字符串值创建控件 [英] C# Create Control From a String Value
本文介绍了C# 从字符串值创建控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以从字符串值创建一个控件吗喜欢
Hi Can I create a Control from String Value Like
来自System.Windows.Forms.TextBox"创建控件
from "System.Windows.Forms.TextBox" create control
推荐答案
你可以使用反射:
var textBoxType = typeof(Control).Assembly.GetType("System.Windows.Forms.TextBox", true);
var textBox = Activator.CreateInstance(textBoxType);
这篇关于C# 从字符串值创建控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文