C# 控件类型作为datacolumn的datatype

C# 控件类型作为datacolumn的datatype,c#,types,datacolumn,C#,Types,Datacolumn,我已经在vb.net中完成了这项工作,但似乎无法在c中运行。我正在尝试将新的数据列的数据类型设置为Label(或System.Windows.Forms.Label),以便此数据表可以引用表单上的控件以更快地编制索引。代码段: DataColumn dc = new DataColumn {DataType = System.Windows.Forms.Label, ColumnName = "labelDate"}; 正在引发错误“'Label'是一个类型,在给定上下文中无效”。同时,“数据

我已经在vb.net中完成了这项工作,但似乎无法在
c
中运行。我正在尝试将新的
数据列的
数据类型
设置为Label(或System.Windows.Forms.Label),以便此数据表可以引用表单上的控件以更快地编制索引。代码段:

DataColumn dc = new DataColumn {DataType = System.Windows.Forms.Label, ColumnName = "labelDate"};

正在引发错误“'Label'是一个类型,在给定上下文中无效”。同时,“数据类型”需要“类型”,所以我不确定这里出了什么问题。

找到了答案,把答案留在这里,以防对任何人都有帮助

DataColumn dc = new DataColumn {DataType = typeof(Label), ColumnName = "labelDate"};
注意,我还尝试了“DataType=Type.GetType(Label)”