Reputation: 163
I am trying to build a DataGrid - Not a DataGridView as it does not seem to be available on Visual Studio 2010.
I want to add rows dynamically (I think I can do that) but in order to display the result I need assign the data to the DataGrid, all the examples say I should use DataSource but Visual Studio insists that this is not available. To code I have found else where is like this.
private void BindToDataView(System.Windows.Controls.DataGrid myGrid)
{
// Create a DataView using the DataTable.
DataTable myTable = new DataTable("Suppliers");
// Insert code to create and populate columns.
DataView myDataView = new DataView(myTable);
myGrid.DataSource = myDataView;
}
What am I doing wrong?
Upvotes: 1
Views: 5063
Reputation: 184526
You pass in a WPF DataGrid (System.Windows.Controls.DataGrid
) and use code meant for a WinForms DataGrid (System.Windows.Forms.DataGrid
).
WPF DataGrids use ItemsSource
.
WinForms DataGrids use DataSource
.
Upvotes: 5