private void button2_Click(object sender, RoutedEventArgs e) { connectionstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:/Project/Book.accdb"; connection = new OleDbConnection(connectionstring); sql = "Select*from Authors"; try { connection.Open(); oledbAdapter = new OleDbDataAdapter(sql, connection); oledbAdapter.Fill(dt); // dataGrid1.DataContext = dt; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } DataGrid dg2 = new DataGrid(); dg2.Height = 200; dg2.Width = 200; dg2.AutoGenerateColumns = true; dg2.AlternatingRowBackground = Brushes.Black; dg2.Background = Brushes.Red; dg2.BorderBrush = Brushes.Pink; dg2.HorizontalGridLinesBrush = Brushes.Black; dg2.DataContext = dt; stackPanel1.Children.Add(dg2); }
stackPanel1.Children.Add(dg2);
dg2.ItemsSource = Your Source
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)