DataTable table = new DataTable();
#region 设置样式
table.Columns.Add("Key");table.Columns.Add("Values");
table.Columns.Add("Values_old");
dataGrid1.TableStyles.Clear(); //清空表头
dataGrid1.DataSource = table;
DataGridColumnStyle dsKey = new DataGridTextBoxColumn();
dsKey.MappingName = "Key";
dsKey.HeaderText = "Key";
dsKey.Width = 60;
DataGridColumnStyle dsValues = new DataGridTextBoxColumn();
dsValues.MappingName = "Values";
dsValues.HeaderText = "Values";
dsValues.Width = 151;
DataGridColumnStyle dsValues_old = new DataGridTextBoxColumn();
dsValues_old.MappingName = "Values_old";
dsValues_old.HeaderText = "Values_old";
dsValues_old.Width = 0;
DataGridTableStyle ts = new DataGridTableStyle();
ts.GridColumnStyles.Add(dsKey);
ts.GridColumnStyles.Add(dsValues);
ts.GridColumnStyles.Add(dsValues_old);
ts.MappingName = table.TableName;
dataGrid1.TableStyles.Add(ts);
#endregion
#region 添加数据
Hashtable ht = WincePda.CommonClass.GetALLOverrideKey();//键,原理的值,现在的值
foreach (DictionaryEntry h in ht)
{
string[] str = h.Value.ToString().Split(',');
if (str[0] == string.Empty)
continue;
DataRow row = table.NewRow();
row["Key"] = str[0];
row["Values_old"] = str[1];
row["Values"] = str[2];
table.Rows.Add(row);
}
#endregion