CurrencyManager クラス
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
Binding オブジェクトのリストを管理します。
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
- 継承
次のコード例では、 TextBox の DataTable列にコントロールをバインドし、バインディングの を CurrencyManager 取得し、その位置を設定します。
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
は CurrencyManager クラスから BindingManagerBase 派生します。 または をBindingContext返すには、 をCurrencyManagerPropertyManager使用します。 返される実際のオブジェクトは、 の プロパティBindingContextにItem[]渡されるデータ ソースとデータ メンバーによって異なります。 データ ソースが (オブジェクトのリストではなく) 1 つのプロパティのみを返すことができるオブジェクトの場合、型は になります PropertyManager。 たとえば、 をデータ ソースとして指定 TextBox すると、 PropertyManager が返されます。 一方、データ ソースが、、または IBindingList インターフェイスをIListIListSource実装するオブジェクトである場合は、 CurrencyManager が返されます。
プロパティは Current 、基になるリスト内の現在の項目を返します。 現在の項目を変更するには、 プロパティを Position 新しい値に設定します。 値は 0 より大きく、プロパティの値より小さくする Count 必要があります。
基になるデータ ソースが インターフェイスを IBindingList 実装し、 プロパティが AllowNew に true
設定されている場合は、 メソッドを AddNew 使用できます。
final |
リストのデータ型を指定します。 |
listposition |
リスト内の CurrencyManager の現在位置を指定します。 |
on |
CurrentChanged イベントのイベント ハンドラーを指定します。 (継承元 BindingManagerBase) |
on |
PositionChanged イベントのイベント ハンドラーを指定します。 (継承元 BindingManagerBase) |
Bindings |
管理されているバインディングのコレクションを取得します。 (継承元 BindingManagerBase) |
Count |
一覧内の項目の数を取得します。 |
Current |
リスト内の現在の項目を取得します。 |
Is |
バインディングが中断されているかどうかを示す値を取得します。 (継承元 BindingManagerBase) |
List |
この CurrencyManager のリストを取得します。 |
Position |
リスト内の現在の位置を取得または設定します。 |
Binding |
データ バインディング操作の完了時に発生します。 (継承元 BindingManagerBase) |
Current |
現在バインドされている項目が変更されると発生します。 (継承元 BindingManagerBase) |
Current |
現在バインドされている項目の状態が変更されたときに発生します。 (継承元 BindingManagerBase) |
Data |
Exception が BindingManagerBase によって処理された場合に発生します。 (継承元 BindingManagerBase) |
Item |
現在の項目が変更されている場合に発生します。 |
List |
リストまたはリスト内の項目が変更された場合に発生します。 |
Meta |
List のメタデータが変更された場合に発生します。 |
Position |
Position プロパティの値が変更された後に発生します。 (継承元 BindingManagerBase) |
製品 | バージョン |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。