我有一个DataTable
,其中包含各种数据类型的列 - int
,string
,bool
,Enum
(如Severity
in下面的例子):
hostTable = new DataTable();
hostTable.Columns.Add("Suspended", typeof(bool));
hostTable.Columns.Add("Succ Tests", typeof(int));
hostTable.Columns.Add("Unsucc Tests", typeof(int));
hostTable.Columns.Add("System Name", typeof(string));
hostTable.Columns.Add("System IP", typeof(string));
hostTable.Columns.Add("Criticality", typeof(Severity));
hostTable.Columns.Add("Alert Email To", typeof(string));
hostTable.Columns.Add("Alert Email Cc", typeof(string));
hostTable.Columns.Add("Likely Impact", typeof(string));
hostTable.Columns.Add("Likely Causes", typeof(string));
hostTable.Columns.Add("Escalation", typeof(string));
hostTable.Rows.Add((bool)hd.IsSuspended, (int)hd.SuccTests, (int)hd.UnSuccTests,
hd.SystemName, hd.SystemIp, (Severity)hd.Criticality, hd.AlertEmailToAddress,
hd.AlertEmailCcAddress, hd.LikelyImpact, hd.LikelyCauses, hd.EscalationInstructions);
dgvHostTable.DataSource = hostTable;
当我将其绑定到DataGridView
时,如何使用此设置显示列: