c#datagridview显示txt指定行
将txt文本中某一行text[i]读到datagridview中代码为:StreamReadersr=newStreamReader(text[i],Encoding.U...
将txt文本中某一行text[i]读到datagridview中
代码为:
StreamReader sr = new StreamReader(text[i],Encoding.UTF8)
string strLine = string.Empty;
strLine = sr.ReadLine();
string[] strList = strLine.Split();
DataRow dr = dt.NewRow();
dr["姓名"] = strList[0];
dr["学号"] = strList[1];
dr["性别"] = strList[2];
dr["年龄"] = strList[3];
dr["专业"] = strList[4];
dr["籍贯"] = strList[5];
dt.Rows.Add(dr);
dataGridView2.DataSource = dt;
第一句StreamReader sr = new StreamReader(text[i],Encoding.UTF8);报错非法字符,应该怎么写?? 展开
代码为:
StreamReader sr = new StreamReader(text[i],Encoding.UTF8)
string strLine = string.Empty;
strLine = sr.ReadLine();
string[] strList = strLine.Split();
DataRow dr = dt.NewRow();
dr["姓名"] = strList[0];
dr["学号"] = strList[1];
dr["性别"] = strList[2];
dr["年龄"] = strList[3];
dr["专业"] = strList[4];
dr["籍贯"] = strList[5];
dt.Rows.Add(dr);
dataGridView2.DataSource = dt;
第一句StreamReader sr = new StreamReader(text[i],Encoding.UTF8);报错非法字符,应该怎么写?? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询