BindingManagerBase 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
동일한 데이터 원본 및 데이터 멤버에 바인딩된 모든 Binding 개체를 관리합니다. 이 클래스는 추상입니다.
public ref class BindingManagerBase abstract
public abstract class BindingManagerBase
type BindingManagerBase = class
Public MustInherit Class BindingManagerBase
- 상속
-
BindingManagerBase
- 파생
예제
다음 코드 예제에서는 특정 데이터 원본에 대 한 BindingManagerBase 반환을 사용 합니다BindingContext. (이 예제에서는 모듈의 선언 섹션에서 선언했다고 myBindingManagerBase 가정합니다.) 그런 다음 이벤트 대리자를 CurrentChanged 이벤트 및 PositionChanged 이벤트에 추가하는 예제입니다. 마지막으로 이 예제에는 속성을 증가 또는 감소 Position 시키고 목록의 첫 번째 또는 마지막 행으로 설정하는 Position 네 가지 메서드(MoveNext, MovePrevious, MoveFirst및MoveLast)가 포함되어 있습니다. 목록의 마지막 행은 속성을 사용하여 결정됩니다 Count .
void GetBindingManagerBase()
{
/* CustomersToOrders is the RelationName of a DataRelation.
Therefore, the list maintained by the BindingManagerBase is the
list of orders that belong to a specific customer in the
DataTable named Customers, found in DataSet1. */
myBindingManagerBase = this->BindingContext[DataSet1, "Customers.CustomersToOrders"];
// Adds delegates to the CurrentChanged and PositionChanged events.
myBindingManagerBase->PositionChanged += gcnew EventHandler( this, &Form1::BindingManagerBase_PositionChanged );
myBindingManagerBase->CurrentChanged += gcnew EventHandler( this, &Form1::BindingManagerBase_CurrentChanged );
}
void BindingManagerBase_PositionChanged( Object^ sender, EventArgs^ /*e*/ )
{
// Prints the new Position of the BindingManagerBase.
Console::Write( "Position Changed: " );
Console::WriteLine( (dynamic_cast<BindingManagerBase^>(sender))->Position );
}
void BindingManagerBase_CurrentChanged( Object^ sender, EventArgs^ /*e*/ )
{
// Prints the new value of the current object.
Console::Write( "Current Changed: " );
Console::WriteLine( (dynamic_cast<BindingManagerBase^>(sender))->Current );
}
void MoveNext()
{
// Increments the Position property value by one.
myBindingManagerBase->Position = myBindingManagerBase->Position + 1;
}
void MovePrevious()
{
// Decrements the Position property value by one.
myBindingManagerBase->Position = myBindingManagerBase->Position - 1;
}
void MoveFirst()
{
// Goes to the first row in the list.
myBindingManagerBase->Position = 0;
}
void MoveLast()
{
// Goes to the last row in the list.
myBindingManagerBase->Position = myBindingManagerBase->Count - 1;
}
private void GetBindingManagerBase()
{
/* CustomersToOrders is the RelationName of a DataRelation.
Therefore, the list maintained by the BindingManagerBase is the
list of orders that belong to a specific customer in the
DataTable named Customers, found in DataSet1. */
myBindingManagerBase =
this.BindingContext[DataSet1, "Customers.CustomersToOrders"];
// Adds delegates to the CurrentChanged and PositionChanged events.
myBindingManagerBase.PositionChanged +=
new EventHandler(BindingManagerBase_PositionChanged);
myBindingManagerBase.CurrentChanged +=
new EventHandler(BindingManagerBase_CurrentChanged);
}
private void BindingManagerBase_PositionChanged
(object sender, EventArgs e)
{
// Prints the new Position of the BindingManagerBase.
Console.Write("Position Changed: ");
Console.WriteLine(((BindingManagerBase)sender).Position);
}
private void BindingManagerBase_CurrentChanged
(object sender, EventArgs e)
{
// Prints the new value of the current object.
Console.Write("Current Changed: ");
Console.WriteLine(((BindingManagerBase)sender).Current);
}
private void MoveNext()
{
// Increments the Position property value by one.
myBindingManagerBase.Position += 1;
}
private void MovePrevious()
{
// Decrements the Position property value by one.
myBindingManagerBase.Position -= 1;
}
private void MoveFirst()
{
// Goes to the first row in the list.
myBindingManagerBase.Position = 0;
}
private void MoveLast()
{
// Goes to the last row in the list.
myBindingManagerBase.Position =
myBindingManagerBase.Count - 1;
}
Private Sub GetBindingManagerBase
' CustomersToOrders is the RelationName of a DataRelation.
' Therefore, the list maintained by the BindingManagerBase is the
' list of orders that belong to a specific customer in the
' DataTable named Customers, found in DataSet.
myBindingManagerBase = Me.BindingContext(DataSet1, _
"Customers.CustomersToOrders")
' Adds delegates to the CurrentChanged and PositionChanged events.
AddHandler myBindingManagerBase.PositionChanged, _
AddressOf BindingManagerBase_PositionChanged
AddHandler myBindingManagerBase.CurrentChanged, _
AddressOf BindingManagerBase_CurrentChanged
End Sub
Private Sub BindingManagerBase_PositionChanged _
(sender As Object, e As EventArgs)
' Prints the new Position of the BindingManagerBase.
Console.Write("Position Changed: ")
Console.WriteLine(CType(sender, BindingManagerBase).Position)
End Sub
Private Sub BindingManagerBase_CurrentChanged _
(sender As Object, e As EventArgs)
' Prints the new value of the current object.
Console.Write("Current Changed: ")
Console.WriteLine(CType(sender, BindingManagerBase).Current)
End Sub
Private Sub MoveNext
' Increments the Position property value by one.
myBindingManagerBase.Position += 1
End Sub
Private Sub MovePrevious
' Decrements the Position property value by one.
myBindingManagerBase.Position -= 1
End Sub
Private Sub MoveFirst
' Goes to the first row in the list.
myBindingManagerBase.Position = 0
End Sub
Private Sub MoveLast
' Goes to the last row in the list.
myBindingManagerBase.Position = _
myBindingManagerBase.Count - 1
End Sub
설명
이렇게 BindingManagerBase 하면 동일한 데이터 원본에 바인딩된 Windows Form에서 데이터 바인딩된 컨트롤을 동기화할 수 있습니다. (데이터 원본에 컨트롤을 간단히 바인딩하는 방법에 대한 자세한 내용은 클래스를 Binding 참조하세요.) 예를 들어 폼에 동일한 데이터 원본과 다른 열에 바인딩된 두 개의 TextBox 컨트롤이 포함되어 있다고 가정합니다. 데이터 원본은 고객 이름을 포함하는 것일 DataTable 수 있지만 열에는 이름과 성이 포함될 수 있습니다. 동일한 고객에 대해 올바른 이름과 성을 함께 표시하려면 두 컨트롤을 동기화해야 합니다. 클래스에서 BindingManagerBase 상속되는 이 동기화는 CurrencyManager데이터 원본의 현재 항목에 대한 포인터를 유지 관리하여 이 동기화를 수행합니다. 컨트롤은 TextBox 동일한 행에 대한 정보를 표시하도록 현재 항목에 바인딩됩니다. 현재 항목이 변경 CurrencyManager 되면 바인딩된 모든 컨트롤에 데이터를 새로 고칠 수 있도록 알립니다. 또한 컨트롤이 Position 가리키는 행 DataTable 을 지정하도록 속성을 설정할 수 있습니다. 데이터 원본에 있는 행 수를 확인하려면 이 속성을 사용합니다 Count .
CurrencyManager 데이터 원본이 반드시 현재 항목 포인터를 유지 관리하지는 않기 때문에 필요합니다. 예를 들어 배열과 ArrayList 개체는 데이터 원본일 수 있지만 현재 항목을 반환하는 속성은 없습니다. 현재 항목을 얻으려면 속성을 사용합니다 Current .
PropertyManager 또한 데이터 원본에서 BindingManagerBase현재 개체의 속성이 아닌 개체의 현재 속성을 유지하는 데 사용됩니다. 이러한 이유로, 또는 Count 속성에 Position 대 한 PropertyManager 설정 하려고 아무 효과가 없습니다.
만들 BindingManagerBase려면 관리되는 데이터 원본에 BindingContext 따라 a 또는 a CurrencyManagerPropertyManager를 반환하는 클래스를 사용합니다.
솔루션 프로그래머는 실제 대상 데이터 원본에 데이터 원본 및 데이터 커넥터 역할을 하는 구성 요소에 직접 BindingSource 컨트롤을 바인딩하는 것이 좋습니다. BindingSource 컨트롤과 대상 간의 통화 관리를 포함하여 단순 데이터 바인딩과 복잡한 데이터 바인딩을 모두 크게 간소화합니다.
구현자 참고
상속BindingManagerBase할 때 다음 추상 멤버AddNew()를 재정의해야 합니다. , ,CountCancelCurrentEdit(), Current, GetItemProperties()EndCurrentEdit(), OnCurrentChanged(EventArgs), RemoveAt(Int32)ResumeBinding()Position, SuspendBinding()및 .UpdateIsBinding()
생성자
| Name | Description |
|---|---|
| BindingManagerBase() |
BindingManagerBase 클래스의 새 인스턴스를 초기화합니다. |
필드
| Name | Description |
|---|---|
| onCurrentChangedHandler |
이벤트에 대한 이벤트 처리기를 지정합니다 CurrentChanged . |
| onPositionChangedHandler |
이벤트에 대한 이벤트 처리기를 지정합니다 PositionChanged . |
속성
| Name | Description |
|---|---|
| Bindings |
관리되는 바인딩의 컬렉션을 가져옵니다. |
| Count |
파생 클래스에서 재정의 BindingManagerBase되는 경우 . |
| Current |
파생 클래스에서 재정의되는 경우 현재 개체를 가져옵니다. |
| IsBindingSuspended |
바인딩이 일시 중단되었는지 여부를 나타내는 값을 가져옵니다. |
| Position |
파생 클래스에서 재정의되는 경우 이 데이터 원본 지점에 바인딩된 컨트롤을 제어하는 내부 목록의 위치를 가져오거나 설정합니다. |
메서드
| Name | Description |
|---|---|
| AddNew() |
파생 클래스에서 재정의되는 경우 기본 목록에 새 항목을 추가합니다. |
| CancelCurrentEdit() |
파생 클래스에서 재정의되면 현재 편집을 취소합니다. |
| EndCurrentEdit() |
파생 클래스에서 재정의되면 현재 편집을 종료합니다. |
| Equals(Object) |
지정된 개체가 현재 개체와 같은지 여부를 확인합니다. (다음에서 상속됨 Object) |
| GetHashCode() |
기본 해시 함수로 사용됩니다. (다음에서 상속됨 Object) |
| GetItemProperties() |
파생 클래스에서 재정의되는 경우 바인딩에 대한 속성 설명자의 컬렉션을 가져옵니다. |
| GetItemProperties(ArrayList, ArrayList) |
지정된 ArrayList을 사용하여 바인딩에 대한 속성 설명자의 컬렉션을 가져옵니다. |
| GetItemProperties(Type, Int32, ArrayList, ArrayList) |
이 BindingManagerBase항목에서 관리하는 항목의 속성 목록을 가져옵니다. |
| GetListName(ArrayList) |
파생 클래스에서 재정의되는 경우 바인딩에 대한 데이터를 제공하는 목록의 이름을 가져옵니다. |
| GetType() |
현재 인스턴스의 Type 가져옵니다. (다음에서 상속됨 Object) |
| MemberwiseClone() |
현재 Object단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
| OnBindingComplete(BindingCompleteEventArgs) |
BindingComplete 이벤트를 발생시킵니다. |
| OnCurrentChanged(EventArgs) |
CurrentChanged 이벤트를 발생시킵니다. |
| OnCurrentItemChanged(EventArgs) |
CurrentItemChanged 이벤트를 발생시킵니다. |
| OnDataError(Exception) |
DataError 이벤트를 발생시킵니다. |
| PullData() |
데이터 바인딩된 컨트롤에서 데이터 원본으로 데이터를 끌어와 정보를 반환하지 않습니다. |
| PushData() |
데이터 원본의 데이터를 데이터 바인딩된 컨트롤로 푸시하여 정보를 반환하지 않습니다. |
| RemoveAt(Int32) |
파생 클래스에서 재정의되는 경우 기본 목록에서 지정된 인덱스의 행을 삭제합니다. |
| ResumeBinding() |
파생 클래스에서 재정의된 경우 데이터 바인딩을 다시 시작합니다. |
| SuspendBinding() |
파생 클래스에서 재정의되면 데이터 바인딩을 일시 중단합니다. |
| ToString() |
현재 개체를 나타내는 문자열을 반환합니다. (다음에서 상속됨 Object) |
| UpdateIsBinding() |
파생 클래스에서 재정의된 경우 바인딩을 업데이트합니다. |
이벤트
| Name | Description |
|---|---|
| BindingComplete |
데이터 바인딩 작업이 완료될 때 발생합니다. |
| CurrentChanged |
현재 바인딩된 항목이 변경되면 발생합니다. |
| CurrentItemChanged |
현재 바인딩된 항목의 상태가 변경되면 발생합니다. |
| DataError |
에 Exception 의해 BindingManagerBase자동으로 처리될 때 발생합니다. |
| PositionChanged |
속성 값 Position 이 변경된 후에 발생합니다. |