我的问题是,有没有办法过滤数据集中的记录并使用该记录来填充datagridview?例如,一个数据表(3列:ID,StudentName,Gender)填充有学生的列表.我有两个数据网格形式即DatagridView1和Datagridview2.DatagridView1就是学生的列表,Gender等于M和DatagridView2就是其中的学生的名单Gender等于F.
在我目前的解决方案中,我正在使用循环.
For each iStud as datarow in iDataset.Tables(0).Rows
      IF iStud.Item("Gender").ToString = "M" Then
            'add this record to DatagridView1
      Else
            'add this record to DatagridView2
      End If
Next
有没有使用循环的方法?
就在这里.您需要做的就是使用过滤数据集SELECT.
例如, 
DatagridView1.Datasource = xSet.Tables("StudentList").SELECT("Gender = 'M'")
DatagridView2.Datasource = xSet.Tables("StudentList").SELECT("Gender = 'F'")
简要说明:
xSet          is the name of the Dataset
StudentList   is the name of the Datatable
Gender        is the name of the Column where you want to filter
UPDATE

| 归档时间: | 
 | 
| 查看次数: | 15437 次 | 
| 最近记录: |