CurrencyManager Klasa

Definicja

Zarządza listą Binding obiektów.

public ref class CurrencyManager : System::Windows::Forms::BindingManagerBase
public class CurrencyManager : System.Windows.Forms.BindingManagerBase
type CurrencyManager = class
    inherit BindingManagerBase
Public Class CurrencyManager
Inherits BindingManagerBase
Dziedziczenie
CurrencyManager

Przykłady

Poniższy przykład kodu wiąże kontrolkę z TextBox kolumną w elemecie DataTable, pobiera CurrencyManager element dla powiązania i ustawia jego położenie.

CurrencyManager^ myCurrencyManager;
void BindControl( DataTable^ myTable )
{
   
   // Bind a TextBox control to a DataTable column in a DataSet.
   textBox1->DataBindings->Add( "Text", myTable, "CompanyName" );
   
   // Specify the CurrencyManager for the DataTable.
   this->myCurrencyManager = dynamic_cast<CurrencyManager^>(this->BindingContext[ myTable ]);
   
   // Set the initial Position of the control.
   this->myCurrencyManager->Position = 0;
}

void MoveNext( CurrencyManager^ myCurrencyManager )
{
   if ( myCurrencyManager->Position == myCurrencyManager->Count - 1 )
   {
      MessageBox::Show( "You're at end of the records" );
   }
   else
   {
      myCurrencyManager->Position += 1;
   }
}

void MoveFirst( CurrencyManager^ myCurrencyManager )
{
   myCurrencyManager->Position = 0;
}

void MovePrevious( CurrencyManager^ myCurrencyManager )
{
   if ( myCurrencyManager->Position == 0 )
   {
      MessageBox::Show( "You're at the beginning of the records." );
   }
   else
   {
      myCurrencyManager->Position -= 1;
   }
}

void MoveLast( CurrencyManager^ myCurrencyManager )
{
   myCurrencyManager->Position = myCurrencyManager->Count - 1;
}
private CurrencyManager myCurrencyManager;
 
 private void BindControl(DataTable myTable){
    // Bind a TextBox control to a DataTable column in a DataSet.
    textBox1.DataBindings.Add("Text", myTable, "CompanyName");
    // Specify the CurrencyManager for the DataTable.
    myCurrencyManager = (CurrencyManager)this.BindingContext[myTable];
    // Set the initial Position of the control.
    myCurrencyManager.Position = 0;
 }
 
 private void MoveNext(CurrencyManager myCurrencyManager){
    if (myCurrencyManager.Position == myCurrencyManager.Count - 1){
       MessageBox.Show("You're at end of the records");
    }
    else{
      myCurrencyManager.Position += 1;
    }
 }
 
 private void MoveFirst(CurrencyManager myCurrencyManager){
    myCurrencyManager.Position = 0;
 }
 
 private void MovePrevious(CurrencyManager myCurrencyManager ){
    if(myCurrencyManager.Position == 0) {
       MessageBox.Show("You're at the beginning of the records.");
    }   
    else{
       myCurrencyManager.Position -= 1;
    }
 }
 
 private void MoveLast(CurrencyManager myCurrencyManager){
    myCurrencyManager.Position = myCurrencyManager.Count - 1;
 }
' Place the next line into the Declarations section of the form.
 Private myCurrencyManager As CurrencyManager
 
 Private Sub BindControl(myTable As DataTable)
    ' Bind a TextBox control to a DataTable column in a DataSet.
    TextBox1.DataBindings.Add("Text", myTable, "CompanyName")
    ' Specify the CurrencyManager for the DataTable.
    myCurrencyManager = CType(me.BindingContext(myTable), CurrencyManager)
    ' Set the initial Position of the control.
    myCurrencyManager.Position = 0
 End Sub
 
 Private Sub MoveNext(myCurrencyManager As CurrencyManager)
    If myCurrencyManager.Position = myCurrencyManager.Count - 1 Then 
       MessageBox.Show("You're at end of the records")
    Else
       myCurrencyManager.Position += 1
    End If
 End Sub
 
 Private Sub MoveFirst(myCurrencyManager As CurrencyManager)
    myCurrencyManager.Position = 0
 End Sub
 
 Private Sub MovePrevious(myCurrencyManager As CurrencyManager)
    If myCurrencyManager.Position = 0 Then
       MessageBox.Show("You're at the beginning of the records.")
    Else
       myCurrencyManager.Position -= 1
    End if
 End Sub
 
 Private Sub MoveLast(myCurrencyManager As CurrencyManager)
    myCurrencyManager.Position = myCurrencyManager.Count - 1
 End Sub

Uwagi

Element CurrencyManager pochodzi z BindingManagerBase klasy . Użyj polecenia , BindingContext aby zwrócić element lub CurrencyManager .PropertyManager Zwracany obiekt jest zależny od źródła danych i elementu członkowskiego danych przekazanego do Item[] właściwości obiektu BindingContext. Jeśli źródło danych jest obiektem, który może zwrócić tylko jedną właściwość (zamiast listy obiektów), typ będzie .PropertyManager Jeśli na przykład określisz źródło TextBox danych, PropertyManager zostanie zwrócona wartość . Jeśli z drugiej strony źródło danych jest obiektem, który implementuje IListinterfejs , IListSourcelub IBindingList , CurrencyManager zostanie zwrócony.

Właściwość Current zwraca bieżący element na liście bazowej. Aby zmienić bieżący element, ustaw Position właściwość na nową wartość. Wartość musi być większa niż 0 i musi być mniejsza niż wartość Count właściwości.

Jeśli bazowe źródło danych implementuje IBindingList interfejs, a AllowNew właściwość jest ustawiona na true, możesz użyć AddNew metody .

Pola

finalType

Określa typ danych listy.

listposition

Określa bieżącą pozycję na CurrencyManager liście.

onCurrentChangedHandler

Określa procedurę obsługi zdarzeń CurrentChanged dla zdarzenia.

(Odziedziczone po BindingManagerBase)
onPositionChangedHandler

Określa procedurę obsługi zdarzeń PositionChanged dla zdarzenia.

(Odziedziczone po BindingManagerBase)

Właściwości

Bindings

Pobiera kolekcję powiązań zarządzanych.

(Odziedziczone po BindingManagerBase)
Count

Pobiera liczbę elementów na liście.

Current

Pobiera bieżący element na liście.

IsBindingSuspended

Pobiera wartość wskazującą, czy powiązanie jest zawieszone.

(Odziedziczone po BindingManagerBase)
List

Pobiera listę dla tego elementu CurrencyManager.

Position

Pobiera lub ustawia pozycję, którą znajdujesz się na liście.

Metody

AddNew()

Dodaje nowy element do listy bazowej.

CancelCurrentEdit()

Anuluje bieżącą operację edycji.

CheckEmpty()

Zgłasza wyjątek, jeśli nie ma listy lub lista jest pusta.

EndCurrentEdit()

Kończy bieżącą operację edycji.

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetItemProperties()

Pobiera kolekcję deskryptora właściwości dla bazowej listy.

GetItemProperties(ArrayList, ArrayList)

Pobiera kolekcję deskryptorów właściwości dla powiązania przy użyciu określonego ArrayListelementu .

(Odziedziczone po BindingManagerBase)
GetItemProperties(Type, Int32, ArrayList, ArrayList)

Pobiera listę właściwości elementów zarządzanych przez ten BindingManagerBaseelement .

(Odziedziczone po BindingManagerBase)
GetListName(ArrayList)

Pobiera nazwę listy dostarczającej dane powiązania przy użyciu określonego zestawu powiązanych właściwości.

GetType()

Type Pobiera bieżące wystąpienie.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
OnBindingComplete(BindingCompleteEventArgs)

BindingComplete Zgłasza zdarzenie.

(Odziedziczone po BindingManagerBase)
OnCurrentChanged(EventArgs)

CurrentChanged Zgłasza zdarzenie.

OnCurrentItemChanged(EventArgs)

CurrentItemChanged Zgłasza zdarzenie.

OnCurrentItemChanged(EventArgs)

CurrentItemChanged Zgłasza zdarzenie.

(Odziedziczone po BindingManagerBase)
OnDataError(Exception)

DataError Zgłasza zdarzenie.

(Odziedziczone po BindingManagerBase)
OnItemChanged(ItemChangedEventArgs)

ItemChanged Zgłasza zdarzenie.

OnMetaDataChanged(EventArgs)

MetaDataChanged Zgłasza zdarzenie.

OnPositionChanged(EventArgs)

PositionChanged Zgłasza zdarzenie.

PullData()

Pobiera dane z kontrolki powiązanej z danymi do źródła danych i nie zwraca żadnych informacji.

(Odziedziczone po BindingManagerBase)
PushData()

Wypycha dane ze źródła danych do kontrolki powiązanej z danymi i nie zwraca żadnych informacji.

(Odziedziczone po BindingManagerBase)
Refresh()

Wymusza ponowne wypełnianie listy powiązanej z danymi.

RemoveAt(Int32)

Usuwa element pod określonym indeksem.

ResumeBinding()

Wznawia powiązanie danych.

SuspendBinding()

Zawiesza powiązanie danych, aby uniemożliwić zmianom aktualizowanie powiązanego źródła danych.

ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)
UpdateIsBinding()

Aktualizacje stan powiązania.

Zdarzenia

BindingComplete

Następuje po zakończeniu operacji powiązania danych.

(Odziedziczone po BindingManagerBase)
CurrentChanged

Występuje, gdy aktualnie powiązany element ulegnie zmianie.

(Odziedziczone po BindingManagerBase)
CurrentItemChanged

Występuje, gdy stan aktualnie powiązanego elementu ulegnie zmianie.

(Odziedziczone po BindingManagerBase)
DataError

Występuje, gdy Exception element jest w trybie dyskretnym obsługiwanym przez BindingManagerBaseelement .

(Odziedziczone po BindingManagerBase)
ItemChanged

Występuje, gdy bieżący element został zmieniony.

ListChanged

Występuje, gdy lista zmienia się lub zmienia element na liście.

MetaDataChanged

Występuje, gdy metadane obiektu List uległy zmianie.

PositionChanged

Występuje po zmianie wartości Position właściwości.

(Odziedziczone po BindingManagerBase)

Dotyczy

Zobacz też