移动从数据表中数据的datagridview在C# [英] Moving data from datatable to datagridview in C#

查看:138
本文介绍了移动从数据表中数据的datagridview在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个不同的数据库文件选择数据,并结合我需要到一个数据表(DT)的数据的C#程序。我需要的所有信息在的DataTable,我希望把它变成一个DataGridView。除了在数据表中的信息,我也有,我会计算为每个我行添加到DataGridView(dataGridView1)DataGridView的两列。

I have a C# program that selects data from two different database files and combines the data that I need into a datatable (dt). All the information I need is in that datatable, and I want to put it into a datagridview. Besides the information in the datatable, I also have two columns in the datagridview that I'll calculate as I add each row to the datagridview (dataGridView1).

我的问题是:我怎样才能让我的数据表(DT)到datagridview的(dataGridView1)?我会做这样的事情:

My question is: How can I get my datatable (dt) into the datagridview (dataGridView1)? Would I do something like this?:

dataGridView1.column("MemberSep") = dt.column("MBRNUM);

我想我可以通过数据表圈,计算我的前两列中的值datagridview的,然后它写的行,直到我读了整个数据表。我从来没有用了。任何帮助,将不胜感激DataGridView控件的工作。

I'm thinking that I could loop through the datatable, calculate the values for my first two columns of the datagridview, and then write it all to a row until I've read the whole datatable. I've never worked with a datagridview control before. Any help would be greatly appreciated.

我的应用程序的图片

推荐答案

设置在DataGridView的数据源数据表

Set the DataGridView's DataSource to the DataTable.

这篇关于移动从数据表中数据的datagridview在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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