views:

36

answers:

1

I'm relatively new to .Net 4 and I am creating my FIRST WPF application using a MDB as a backend datasource.

I designed my UI. I have a TextField (called Name), a Combobox (called Division) and a DataGrid (called dataGrid1).

The only problem I'm having is figuring out how to link my DataGrid to display data from the DataSource. and load the data in the Windows1_Loaded method.

Thanks

+1  A: 

The five second answer is you want to set the DataGrid's ItemsSource property to your data. You can do this in the Loaded event, but doing so in the XAML is better practice. Of course, if it's your first application, either is fine for now.

This CodeProject entry has a ton of examples on how to use the WPF DataGrid. Hopefully they'll be of help to you, I've never tried to use an MDB file before.

JustABill
I'm sorry for not being specific. I can't figure out how to run"SELECT * FROM tblStudents" and using a dataGrid.How do I configure a DataGrid to dynamically determine the number of columns? How do I configure a Datagrid to display only 2 fields (out of the 6 that are in the table)?
Cocoa Dev
The WPF DataGrid has an AutoGenerateColumns property (boolean). If it's set to True, the DataGrid will automatically generate one column for each column in the data provided to it (with the Header set to the column name). If it's false, you have to manually specify the columns. There's no way to use a subset of the auto-generated columns, it's all or nothing.As for the SQL part, I'm not sure I know enough to help you, but I think you just need to get the result of that query and assign it to the DataGrid's ItemsSource.
JustABill