BindingContext.Item[] 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
를 가져옵니다 BindingManagerBase.
오버로드
| Name | Description |
|---|---|
| Item[Object, String] |
BindingManagerBase 지정된 데이터 원본 및 데이터 멤버와 연결된 값을 가져옵니다. |
| Item[Object] |
BindingManagerBase 지정된 데이터 원본과 연결된 데이터를 가져옵니다. |
Item[Object, String]
- Source:
- BindingContext.cs
- Source:
- BindingContext.cs
- Source:
- BindingContext.cs
- Source:
- BindingContext.cs
- Source:
- BindingContext.cs
BindingManagerBase 지정된 데이터 원본 및 데이터 멤버와 연결된 값을 가져옵니다.
public:
property System::Windows::Forms::BindingManagerBase ^ default[System::Object ^, System::String ^] { System::Windows::Forms::BindingManagerBase ^ get(System::Object ^ dataSource, System::String ^ dataMember); };
public System.Windows.Forms.BindingManagerBase this[object dataSource, string dataMember] { get; }
public System.Windows.Forms.BindingManagerBase this[object dataSource, string? dataMember] { get; }
member this.Item(obj * string) : System.Windows.Forms.BindingManagerBase
Default Public ReadOnly Property Item(dataSource As Object, dataMember As String) As BindingManagerBase
매개 변수
- dataSource
- Object
특정 BindingManagerBase과 연결된 데이터 원본입니다.
- dataMember
- String
특정 BindingManagerBase정보로 확인되는 정보를 포함하는 탐색 경로입니다.
속성 값
BindingManagerBase 지정된 데이터 원본 및 데이터 멤버에 대한 값입니다.
예외
지정한 dataMember 항목이 데이터 원본 내에 없습니다.
예제
다음 코드 예제에서는 특정 바인딩에 Item[] 대 한 검색 BindingManagerBase 을 사용 하는 방법을 보여 줍니다. 또한 컨트롤 값 중 하나가 변경될 때 동일한 데이터 원본에 BindingComplete 바인딩된 여러 컨트롤이 동기화된 상태로 유지되도록 이벤트를 처리하는 BindingManagerBase 방법도 보여 줍니다. 이 예제를 실행하려면 코드를 Windows Form에 붙여넣고 양식의 생성자 또는 InitializeControlsAndData 이벤트 처리 메서드에서 메서드를 호출 Load 합니다.
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(); ;
}
Dim WithEvents bmb As BindingManagerBase
Private Sub InitializeControlsAndData()
' Initialize the controls and set location, size and
' other basic properties.
Me.dataGridView1 = New DataGridView()
Me.textBox1 = New TextBox()
Me.textBox2 = New TextBox()
Me.dataGridView1.ColumnHeadersHeightSizeMode = _
DataGridViewColumnHeadersHeightSizeMode.AutoSize
Me.dataGridView1.Dock = DockStyle.Top
Me.dataGridView1.Location = New Point(0, 0)
Me.dataGridView1.Size = New Size(292, 150)
Me.textBox1.Location = New Point(132, 156)
Me.textBox1.Size = New Size(100, 20)
Me.textBox2.Location = New Point(12, 156)
Me.textBox2.Size = New Size(100, 20)
Me.ClientSize = New Size(292, 266)
Me.Controls.Add(Me.textBox2)
Me.Controls.Add(Me.textBox1)
Me.Controls.Add(Me.dataGridView1)
' Declare the DataSet and add a table and column.
Dim set1 As 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)
' Get the BindingManagerBase for this binding.
bmb = Me.BindingContext(set1, "Menu")
End Sub
Private Sub bmb_BindingComplete(ByVal sender As Object, ByVal e As BindingCompleteEventArgs) _
Handles bmb.BindingComplete
' Check if the data source has been updated, and that no error has occurred.
If e.BindingCompleteContext = BindingCompleteContext.DataSourceUpdate _
AndAlso e.Exception Is Nothing Then
' If not, end the current edit.
e.Binding.BindingManagerBase.EndCurrentEdit()
End If
End Sub
설명
데이터 원본에 여러 개체가 BindingManagerBase 포함된 개체 집합 Binding 을 관리할 때 이 오버로드를 사용합니다. 예를 들어 개체로 DataSet 연결된 DataTable 여러 DataRelation 개체를 포함할 수 있습니다. 이 경우 올바른 BindingContext반환을 사용하려면 탐색 경로가 BindingManagerBase 필요합니다.
메모
null되지 않습니다.
Binding 가능한 데이터 원본 목록 및 컨트롤과 데이터 원본 간에 바인딩을 만드는 방법에 대한 자세한 내용은 클래스를 참조하세요.
원하는 BindingManagerBase 항목이 목록을 관리하는 경우 탐색 경로도 목록으로 끝나야 합니다. 예를 들어 다음 C# 코드는 TextBox 주문 테이블의 주문 날짜에 컨트롤을 바인딩합니다. 탐색 경로에는 TableName, RelationName및 ColumnName. 그러나 목록으로 BindingManagerBase 확인되는 and TableName 만 RelationName 사용하여 검색해야 합니다.
// The navigation path for a Binding ends with a property.
textBox1.DataBindings.Add
("Text", dataSet1, "Customers.custToOrders.OrderDate");
// The navigation path for the BindingManagerBase ends with a list.
BindingManagerBase bmOrders = this.BindingContext
[dataSet1, "Customers.custToOrders"];
반환할 BindingManagerBase때 동일한 데이터 원본 Binding 을 사용하고 탐색 경로만 수정해야 합니다.
메서드를 Contains 사용하여 원하는 BindingManagerBase 항목이 이미 있는지 확인합니다.
추가 정보
적용 대상
Item[Object]
- Source:
- BindingContext.cs
- Source:
- BindingContext.cs
- Source:
- BindingContext.cs
- Source:
- BindingContext.cs
- Source:
- BindingContext.cs
BindingManagerBase 지정된 데이터 원본과 연결된 데이터를 가져옵니다.
public:
property System::Windows::Forms::BindingManagerBase ^ default[System::Object ^] { System::Windows::Forms::BindingManagerBase ^ get(System::Object ^ dataSource); };
public System.Windows.Forms.BindingManagerBase this[object dataSource] { get; }
member this.Item(obj) : System.Windows.Forms.BindingManagerBase
Default Public ReadOnly Property Item(dataSource As Object) As BindingManagerBase
매개 변수
- dataSource
- Object
특정 BindingManagerBase과 연결된 데이터 원본입니다.
속성 값
지정된 데이터 원본에 대한 A BindingManagerBase 입니다.
예제
다음 코드 예제에서는 세 BindingManagerBase 개의 개체를 반환합니다. 하나는 컨트롤DataView에 속하는 ArrayList 개체에 대한 DataSourceBindingTextBox 개체입니다.
void ReturnBindingManagerBase()
{
// Get the BindingManagerBase for a DataView.
BindingManagerBase^ bmCustomers = this->BindingContext[ myDataView ];
/* Get the BindingManagerBase for an ArrayList. */
BindingManagerBase^ bmOrders = this->BindingContext[ myArrayList ];
// Get the BindingManagerBase for a TextBox control.
BindingManagerBase^ baseArray = this->BindingContext[ textBox1->DataBindings[ nullptr ]->DataSource ];
}
private void ReturnBindingManagerBase()
{
// Get the BindingManagerBase for a DataView.
BindingManagerBase bmCustomers =
this.BindingContext [myDataView];
/* Get the BindingManagerBase for an ArrayList. */
BindingManagerBase bmOrders =
this.BindingContext[myArrayList];
// Get the BindingManagerBase for a TextBox control.
BindingManagerBase baseArray =
this.BindingContext[textBox1.DataBindings[0].DataSource];
}
Private Sub ReturnBindingManagerBase()
' Get the BindingManagerBase for a DataView.
Dim bmCustomers As BindingManagerBase = _
Me.BindingContext(myDataView)
' Get the BindingManagerBase for an ArrayList.
Dim bmOrders As BindingManagerBase = _
Me.BindingContext(myArrayList)
' Get the BindingManagerBase for a TextBox control.
Dim baseArray As BindingManagerBase = _
Me.BindingContext(Text1.DataBindings(0).DataSource)
End Sub
설명
원하는 탐색 경로가 BindingManagerBase 필요하지 않은 경우 이 오버로드를 사용합니다. 예를 들어, 개체 집합 BindingManagerBase 을 사용하거나 Binding 해당 개체로 ArrayList관리하는 DataTable 경우 DataSource 탐색 경로가 필요하지 않습니다.
메모
속성은 Item[] 항상 을 BindingManagerBase반환하고 반환 null하지 않습니다.
Binding 가능한 데이터 원본 목록 및 컨트롤과 데이터 원본 간에 바인딩을 만드는 방법에 대한 자세한 내용은 클래스를 참조하세요.