Search code examples
c#wpfdatagrid

DatagridView bind from dictionary keys


I'm trying to fill the DatagridView rows with my dictionary values keys, but instead it's filling with the length (I believe it is the Key length).

My dictionary is filled like this:

  • Key: Name of files
  • Values: a class columns which represents the columns of this file

Code:

var dictFilesAndColumns = inputFiles.GetFilesWithColumns(txtSearchPath.Text);
DGFiles.DataSource = dictFilesAndColumns.Keys.ToList();

In this last line is where I'm getting the length of the key. How could I get the key value?


Solution

  • You can try this way to achieve it:

    dictFilesAndColumns.Values.ToList();