过滤没有绑定源的datagridview副本

时间:2018-04-29 05:25:44

标签: vb.net data-binding filter datagridview filtering

我使用以下代码获取datagidview#1的副本:

<?php session_start(); ?>

此代码将所有标题,列和行复制到第二个Private Sub copytable() Dim sourceGrid As DataGridView = Me.DataGridView1 Dim targetGrid As DataGridView = Me.DataGridView2 Dim targetRows = New List(Of DataGridViewRow) For Each sourceRow As DataGridViewRow In sourceGrid.Rows If (Not sourceRow.IsNewRow) Then Dim targetRow = CType(sourceRow.Clone(), DataGridViewRow) For Each cell As DataGridViewCell In sourceRow.Cells targetRow.Cells(cell.ColumnIndex).Value = cell.Value Next targetRows.Add(targetRow) End If Next 'Clear target columns and then clone all source columns. targetGrid.Columns.Clear() For Each column As DataGridViewColumn In sourceGrid.Columns targetGrid.Columns.Add(CType(column.Clone(), DataGridViewColumn)) Next 'It's recommended to use the AddRange method (if available) 'when adding multiple items to a collection. targetGrid.Rows.AddRange(targetRows.ToArray()) End Sub ,然后我想过滤第二个DataGridView,但我不能(BindingSource.Filter)绑定源不存在。 如何为第二个DataGridView ??

创建Bindingsource

0 个答案:

没有答案