本文整理汇总了C#中System.Windows.Forms.BindingCompleteEventArgs.Binding属性的典型用法代码示例。如果您正苦于以下问题:C# BindingCompleteEventArgs.Binding属性的具体用法?C# BindingCompleteEventArgs.Binding怎么用?C# BindingCompleteEventArgs.Binding使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Windows.Forms.BindingCompleteEventArgs
的用法示例。
在下文中一共展示了BindingCompleteEventArgs.Binding属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeControlsAndData
private void InitializeControlsAndData()
{
// Initialize the controls and set location, size and
// other basic properties.
this.dataGridView1 = new DataGridView();
this.textBox1 = new TextBox();
this.textBox2 = new TextBox();
this.dataGridView1.ColumnHeadersHeightSizeMode =
DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Dock = DockStyle.Top;
this.dataGridView1.Location = new Point(0, 0);
this.dataGridView1.Size = new Size(292, 150);
this.textBox1.Location = new Point(132, 156);
this.textBox1.Size = new Size(100, 20);
this.textBox2.Location = new Point(12, 156);
this.textBox2.Size = new Size(100, 20);
this.ClientSize = new Size(292, 266);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.dataGridView1);
// Declare the DataSet and add a table and column.
DataSet set1 = new DataSet();
set1.Tables.Add("Menu");
set1.Tables[0].Columns.Add("Beverages");
// Add some rows to the table.
set1.Tables[0].Rows.Add("coffee");
set1.Tables[0].Rows.Add("tea");
set1.Tables[0].Rows.Add("hot chocolate");
set1.Tables[0].Rows.Add("milk");
set1.Tables[0].Rows.Add("orange juice");
// Add the control data bindings.
dataGridView1.DataSource = set1;
dataGridView1.DataMember = "Menu";
textBox1.DataBindings.Add("Text", set1,
"Menu.Beverages", true, DataSourceUpdateMode.OnPropertyChanged);
textBox2.DataBindings.Add("Text", set1,
"Menu.Beverages", true, DataSourceUpdateMode.OnPropertyChanged);
BindingManagerBase bmb = this.BindingContext[set1, "Menu"];
bmb.BindingComplete += new BindingCompleteEventHandler(bmb_BindingComplete);
}
private void bmb_BindingComplete(object sender, BindingCompleteEventArgs e)
{
// Check if the data source has been updated, and that no error has occurred.
if (e.BindingCompleteContext ==
BindingCompleteContext.DataSourceUpdate && e.Exception == null)
// If not, end the current edit.
e.Binding.BindingManagerBase.EndCurrentEdit(); ;
}