本文整理匯總了VB.NET中System.Windows.Forms.BindingContext類的典型用法代碼示例。如果您正苦於以下問題:VB.NET BindingContext類的具體用法?VB.NET BindingContext怎麽用?VB.NET BindingContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了BindingContext類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: BindControls
Protected Sub BindControls()
' Create two Binding objects for the first two TextBox
' controls. The data-bound property for both controls
' is the Text property. The data source is a DataSet
' (ds). The data member is the string
' "TableName.ColumnName".
text1.DataBindings.Add(New Binding _
("Text", ds, "customers.custName"))
text2.DataBindings.Add(New Binding _
("Text", ds, "customers.custID"))
' Bind the DateTimePicker control by adding a new Binding.
' The data member of the DateTimePicker is a
' TableName.RelationName.ColumnName string.
DateTimePicker1.DataBindings.Add(New Binding _
("Value", ds, "customers.CustToOrders.OrderDate"))
' Add event delegates for the Parse and Format events to a
' new Binding object, and add the object to the third
' TextBox control's BindingsCollection. The delegates
' must be added before adding the Binding to the
' collection; otherwise, no formatting occurs until
' the Current object of the BindingManagerBase for
' the data source changes.
Dim b As Binding = New Binding _
("Text", ds, "customers.custToOrders.OrderAmount")
AddHandler b.Parse, New ConvertEventHandler(AddressOf CurrencyStringToDecimal)
AddHandler b.Format, New ConvertEventHandler(AddressOf DecimalToCurrencyString)
text3.DataBindings.Add(b)
' Get the BindingManagerBase for the Customers table.
bmCustomers = Me.BindingContext(ds, "Customers")
' Get the BindingManagerBase for the Orders table using the
' RelationName.
bmOrders = Me.BindingContext(ds, "customers.CustToOrders")
' Bind the fourth TextBox control's Text property to the
' third control's Text property.
text4.DataBindings.Add("Text", text3, "Text")
End Sub