将CSV读取到网格中 [英] Reading a CSV into a Grid

查看:87
本文介绍了将CSV读取到网格中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在根据此MSDN文章将CSV读入数据表并填充网格: Datagrid 阅读CSV ,效果很好,但是我迷上了一件事.我希望CSV的第一行是网格的列标题行,而不是列#.我已经使用了一段时间,但无法解决该问题.

任何人对此主题的任何想法,我将不胜感激.

谢谢

解决方案

我正在根据此MSDN文章将CSV读取到数据表中并填充网格:  Datagrid 阅读CSV ,效果很好,但是我迷上了一件事.我希望CSV的第一行是网格的列标题行,而不是列#.我已经使用了一段时间,但无法解决该问题.

任何人对此主题的任何想法,我将不胜感激.

谢谢

罗德尼,

我没有阅读链接-但鉴于您在此处所说的内容,让我建议您建立自己的数据表(在内存中),然后随时可以设置它.

使用TextFieldParser读取数据,然后从中填充数据表(或者,替代地,将封装从文本文件读取的数据的类).


I'm reading a CSV into a datatable and populating a grid based on this MSDN article: Datagrid Read CSV, it works wonderfully, but I'm stumped on one thing. I want the first row of my CSV to be the column header row of my grid, not Column #. I've worked with it for a while and just can't work out how to do this.

I would appreciate any thoughts anyone might have on this topic.

Thanks 

解决方案

I'm reading a CSV into a datatable and populating a grid based on this MSDN article: Datagrid Read CSV, it works wonderfully, but I'm stumped on one thing. I want the first row of my CSV to be the column header row of my grid, not Column #. I've worked with it for a while and just can't work out how to do this.

I would appreciate any thoughts anyone might have on this topic.

Thanks 

Rodney,

I haven't read through the link - but given what you stated here, let me suggest that you build your own datatable (in memory) and you can set it up in anyway that you want.

Use a TextFieldParser to read the data then populate the datatable from that (or, alternately, a class which will encapsulate the data read in from the text file).


这篇关于将CSV读取到网格中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆