ControlBindingsCollection.Item[String] 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得由控制項屬性名稱指定的 Binding。
public:
property System::Windows::Forms::Binding ^ default[System::String ^] { System::Windows::Forms::Binding ^ get(System::String ^ propertyName); };
public System.Windows.Forms.Binding this[string propertyName] { get; }
member this.Item(string) : System.Windows.Forms.Binding
Default Public ReadOnly Property Item(propertyName As String) As Binding
參數
- propertyName
- String
資料繫結控制項上的屬性名稱。
屬性值
將指定的控制項屬性繫結至資料來源的 Binding。
範例
下列程式碼範例會從 ControlBindingsCollection 傳回單 Binding 一 。
void PrintValue()
{
ControlBindingsCollection^ myControlBindings;
myControlBindings = textBox1->DataBindings;
// Get the Binding for the Text property.
Binding^ myBinding = myControlBindings[ "Text" ];
// Assuming the data source is a DataTable.
DataRowView^ drv;
drv = dynamic_cast<DataRowView^>(myBinding->BindingManagerBase->Current);
// Assuming a column named S"custName" exists, print the value.
Console::WriteLine( drv[ "custName" ] );
}
private void PrintValue()
{
ControlBindingsCollection myControlBindings;
myControlBindings = textBox1.DataBindings;
// Get the Binding for the Text property.
Binding myBinding = myControlBindings["Text"];
// Assuming the data source is a DataTable.
DataRowView drv;
drv = (DataRowView) myBinding.BindingManagerBase.Current;
// Assuming a column named "custName" exists, print the value.
Console.WriteLine(drv["custName"]);
}
Private Sub PrintValue()
Dim myControlBindings As ControlBindingsCollection = _
textBox1.DataBindings
' Get the Binding for the Text property.
Dim myBinding As Binding = myControlBindings("Text")
' Assuming the data source is a DataTable.
Dim drv As DataRowView = _
CType( myBinding.BindingManagerBase.Current, DataRowView)
' Assuming a column named "custName" exists, print the value.
Console.WriteLine(drv("custName"))
End Sub
備註
如果指定的屬性不符合集合中的系結,則 Item[] 傳 null
回 。