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?
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
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.