如何使用DataGridView绑定字符串数组 [英] how to bind an array of string with DataGridView
本文介绍了如何使用DataGridView绑定字符串数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
我正在C#Windows应用程序VS2005上工作,我选择了文本文件,然后以字符串数组形式输入文件,现在我必须在数据网格视图中逐行输入数组,但是我不能做同样的事情
在数组中,我现在具有的行数和列数现在我想将所有包含列的行放在数据网格视图中
有人可以帮我吗
Hi All
I am working on C# windows application VS2005 where I selected text file and enter the file in string array now I have to enter row by row of the array in a data grid view but I am not able to do the same
In the array I have number of rows with number of columns now I want to put all the rows with the columns in the data grid view
Can any one help me please
推荐答案
如此处所述
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.datasource.aspx [ ^ ]
DataGridView
类支持标准Windows窗体数据绑定模型.这意味着数据源可以是实现以下接口之一的任何类型:
IList
接口,包括one-dimensional arrays
.
IListSource
接口,例如DataTable和DataSet类.
IBindingList
接口,例如BindingList< t>,课.
IBindingListView
接口,例如BindingSource类.
Array
类实现IList
接口.因此,您可以将DataGridView.DataSource
设置为数组.
As explained here
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.datasource.aspx[^]
TheDataGridView
class supports the standard Windows Forms data-binding model. This means the data source can be of any type that implements one of the following interfaces:
TheIList
interface, includingone-dimensional arrays
.
TheIListSource
interface, such as the DataTable and DataSet classes.
TheIBindingList
interface, such as the BindingList<t> class.
TheIBindingListView
interface, such as the BindingSource class.
TheArray
class implementsIList
interface. Hence, you can setDataGridView.DataSource
to your array.
这篇关于如何使用DataGridView绑定字符串数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文