Export DataBase (.mdb / .accdb) to .csv with row selection

前端 未结 1 1683
情歌与酒
情歌与酒 2021-01-29 10:46

What I must do:

I Need to load a Database, search entries and Export the selected columns.

The Problem:

I got

相关标签:
1条回答
  • 2021-01-29 10:54

    There is a SelectedItems property that will return the selected items in the DataGrid. In your case you could each such item to a DataRowView, e.g.:

    StringBuilder sb = new StringBuilder();
    foreach(var selectedRow in DataGrid_Table.SelectedItems.OfType<DataRowView>())
    {
        foreach(DataColumn column in selectedRow.DataView.Table.Columns)
        {
            sb.Append(selectedRow[column.ColumnName] + ";");
        }
        sb.Append(Environment.NewLine);
    }
    
    string export = sb.ToString();
    
    0 讨论(0)
提交回复
热议问题