DataSet, BindingSource, BindingNavigator Relationship

Multiple Bindings caused dataBing weird????

Text.DataBindings.Add(new Binding("Text", bs1, "Index_Code"));

Text.DataBindings.Add(new Binding("Text", bs2, "Index_Code"));

        BindingSource bs = new BindingSource();
DataTable table = new DataTable(); table.Columns.Add("Name", typeof(string));
table.Columns.Add("Value", typeof(int)); table.Rows.Add("A", );
table.Rows.Add("B", ); //comboBox1.DataSource = table;
//comboBox1.DisplayMember = "Name";
//comboBox1.ValueMember = "Value";
////comboBox1.DataBindings.Add();
//comboBox1.SelectedIndex = -1; bs = new BindingSource();
bs.DataSource = table;
bindingNavigator1.BindingSource = bs; textBox1.DataBindings.Add(new Binding("Text", bs, "Name"));
private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
{ DataRowView row = (DataRowView)bs.Current; row["Name"] = "C";
row["Value"] = ; //row.IsNew is true; int i = table.Rows.Count; // = 2
bs.EndEdit(); //commit to datatable => dataSource get updated
i = table.Rows.Count; // = 3 if (row.IsNew) //false
{
MessageBox.Show("new row");
}
}
上一篇:Javascript 事件(一)


下一篇:Jenkins学习三:介绍一些Jenkins的常用功能