简体   繁体   English

手动将列表框/数据网格视图与数据表绑定VS将其与数据集绑定。在c#winForms中,数据表[0]

[英]Binding a listbox/datagrid view manually with Data Table Vs binding it with Data Sets.Data Table[0] in c# winForms

There are two ways in c# that I can bind my listbox with a datasource: 1) Query the SQL Server 2008 db and the query will return a Data Table which can use it to bind it to list box. 我可以使用两种方法在c#中将列表框与数据源绑定:1)查询SQL Server 2008数据库,查询将返回一个数据表,可以使用该数据表将其绑定到列表框。 2) Create a new Data Set by right-clicking in the solution explorer and going through the wizard to complete it and finally calling the dataset.fill method to fill the data table which I can bind it to my list box. 2)通过在解决方案资源管理器中右键单击并通过向导来完成它来创建一个新的数据集,最后调用dataset.fill方法来填充数据表,我可以将其绑定到我的列表框中。

I have a list box which displays the names of forms that I have created in C#. 我有一个列表框,显示我在C#中创建的表单的名称。 Basically this is used to grant which user has right on which form. 基本上,这用于授予哪个用户有权使用哪种表单。

My question is which method should I go for? 我的问题是我应该选择哪种方法? Currently I'm using method 1. Same question also goes for a data grid view. 当前,我正在使用方法1。数据网格视图也有同样的问题。

It dosn't make any difference. 没关系。

DataSet.Tables[integer] is a DataTable DataSet.Tables[integer]是一个DataTable

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM