C# - 重命名 DataView 列

C# - Rename DataView Columns

我正在使用 DataView。我从数据表中复制一些列并将其插入到 DataView 中。由于一些要求,我需要添加一些重复的列。但是,它通过 DuplicateColumnName 异常。你能帮忙吗?有没有其他方法可以将DataView数据复制到DataTable?

stringarr = new string[] { "ML#", "Address", "Purchaser","Address","Purchaser", "Sold Price", "State", "Taxes", "Town", "Zip", "District", "Section", "Block", "Lot", "Owner" };

    DataTable distinctValues = new dataTable();
    if (cbMLSDataType.SelectedIndex == 1)
        {
            distinctValues = view.ToTable(false, stringarr);
        }
        else if (cbMLSDataType.SelectedIndex == 2)
        {
            distinctValues = view.ToTable(false, stringarr);
        }

复制视图的值。

view.ToTable()

复制源视图但不复制DataView的过滤数据。

view.Table.Copy()

复制源数据表的结构。

view.Table.Clone()