日期:2014-05-17 浏览次数:20451 次
DataTable dt = new DataTable(); DataTable dtab = new DataTable(); private void ChooseBtn_Click(object sender, RoutedEventArgs e) { dt = GetImportExcel(); if (dt != null && dt.Columns.Count > 0) { dtab.Columns.Add("旧的列名"); dtab.Columns.Add("新的列名"); for (int i = 0; i < dt.Columns.Count; i++) { DataRow dr = dtab.NewRow(); dr[0] = dt.Columns[i].ColumnName; dr[1] = GetCombox(); dtab.Rows.Add(dr); } gridheader.ItemsSource = dtab.DefaultView; } } public ComboBox GetCombox() { ComboBox com = new ComboBox(); com.Width = 150; com.Items.Add("姓名"); com.Items.Add("年龄"); com.Items.Add("性别"); com.Items.Add("身高"); com.SelectedIndex = 0; return com; }