void GetFiledsTxt() { var ofd = new OpenFileDialog() { Filter = "文本文件(*.txt)|*.txt", Multiselect = false }; if (ofd.ShowDialog() == DialogResult.Cancel) return; DataTable dtmbClone = new DataTable(); this.btgetfdtxt.Text = ofd.FileName; dtmbClone.Clear(); string line = string.Empty; dtmbClone.Columns.Add("input", typeof(string)); dtmbClone.Columns.Add("sysfileds", typeof(string)); StreamReader sr = new StreamReader(ofd.FileName, Encoding.GetEncoding("GB2312")); while ((line = sr.ReadLine()) != null) { if (line.ToString().Length > 0) { DataRow dr = dtmbClone.NewRow(); dr["input"] = line.ToString(); dtmbClone.Rows.Add(dr); } } sr.Close(); this.gridControl1.DataSource = dtmbClone; }