T
Tony Johansson
Hello!
I just wonder what is the difference if I use the code marked with 1 below
compared to using code marked with 2
In the code marked with 1 I use a BindingSource
but in the code marked with 2 I assign a DataTable to the DataSource of the
DataGridView.
So what I can't really understand is why do I have to use a BindingSource in
the code marked with 1.
public partial class Form1 : Form
{
NorthwindDataSet ds = new NorthwindDataSet();
string conStr = @"Data Source=.\SQLExpress;Initial
Catalog=Northwind;Integrated Security=True;";
public Form1()
{
InitializeComponent();
NorthwindDataSetTableAdapters.ProductsTableAdapter productsTA =
new NorthwindDataSetTableAdapters.ProductsTableAdapter();
productsTA.Fill(ds.Products);
1 BindingSource bs = new BindingSource(ds, "Products");
1 myGrid.DataSource = bs;
2 myGrid.DataSource = ds.Tables["Products"];
}
}
//Tony
I just wonder what is the difference if I use the code marked with 1 below
compared to using code marked with 2
In the code marked with 1 I use a BindingSource
but in the code marked with 2 I assign a DataTable to the DataSource of the
DataGridView.
So what I can't really understand is why do I have to use a BindingSource in
the code marked with 1.
public partial class Form1 : Form
{
NorthwindDataSet ds = new NorthwindDataSet();
string conStr = @"Data Source=.\SQLExpress;Initial
Catalog=Northwind;Integrated Security=True;";
public Form1()
{
InitializeComponent();
NorthwindDataSetTableAdapters.ProductsTableAdapter productsTA =
new NorthwindDataSetTableAdapters.ProductsTableAdapter();
productsTA.Fill(ds.Products);
1 BindingSource bs = new BindingSource(ds, "Products");
1 myGrid.DataSource = bs;
2 myGrid.DataSource = ds.Tables["Products"];
}
}
//Tony