如何从两个表中的文本文件中获取数据,并使用C#.net显示在不同的datagridview中? [英] how to fetch data from text file with two tables and show in the different datagridview using C#.net?

查看:69
本文介绍了如何从两个表中的文本文件中获取数据,并使用C#.net显示在不同的datagridview中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用两个表从文本文件中获取数据并使用C#.net显示在不同的datagridview中?



我的文本文件名是test.txt



table1



A B -----专栏名称



1 1



3 7



5 3







table2



A B -----专栏名称



3 6



7 4



5 7







现在我有两个datagridview dgvTab1和dgvTab2现在我想要使用列名称(AB)在这些datagridview中填充这些测试文本值。并使用C#添加删除更新操作。如果你有任何解决方案,请给我。



提前谢谢

how to fetch data from text file with two tables and show in the different datagridview using C#.net?

my text file name is test.txt

table1

A B ----- column name

1 1

3 7

5 3



table2

A B ----- column name

3 6

7 4

5 7



now i have two datagridview dgvTab1 and dgvTab2 now i want to populate those test text value in these datagridview with column name(A B). and add delete update operation using C#. plz if u have any solution, give me.

thanks in advance

推荐答案

我们不能回答:文本文件没有表格,行或列 - 它几乎没有线条(这些只是对特定系统内容的基本解释。



所以我们不能告诉你如何从文本文件中读取两个数据表,因为我们不知道数据是如何组织的,并且表示这是一行并且这是一个新表的开始,更不用说这是一个专栏和这是下一栏。你需要坐下来看看你的数据并完成所有这些工作。但是当然,哪一次,你将有90%你自己整理出来并准备好编码的文件处理算法......:笑:



在两个DataGridViews中显示它很简单:将你文件中的每个表加载到一个单独的DataTable,并将其设置为DataGridView.DataSource参数 - 系统将采用ca.为你做的。
We can't answer that: a text file doesn't have tables, rows or columns - it barely has lines (and those are just a basic interpretation of the content for a particular system.

So we can't tell you how to read two tables of data from a text file because we have no idea how the data is organised and whet indicates that "this is a row" and "this is the start of a new table", much less what says "This is a column" and "this is the next column". You need to sit down, look at your data and work all of that out. But which time, of course, you will have 90% of the file processing algorithm sorted out yourself and ready for coding...:laugh:

Displaying in two DataGridViews it trivial: load each table from your file into a separate DataTable, and set it as the DataGridView.DataSource parameter - the system will take care of it for you.


这篇关于如何从两个表中的文本文件中获取数据,并使用C#.net显示在不同的datagridview中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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