BindingCompleteEventArgsとは? わかりやすく解説

BindingCompleteEventArgs クラス

メモ : このクラスは、.NET Framework version 2.0 で新しく追加されたものです。

BindingComplete イベントのデータを提供します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Class BindingCompleteEventArgs
    Inherits CancelEventArgs
Dim instance As BindingCompleteEventArgs
public class BindingCompleteEventArgs : CancelEventArgs
public ref class BindingCompleteEventArgs :
 public CancelEventArgs
public class BindingCompleteEventArgs extends
 CancelEventArgs
public class BindingCompleteEventArgs extends
 CancelEventArgs
解説解説
使用例使用例

BindingComplete イベントを処理するコード例を次に示します。このコードを実行するには、空のコード ファイルに貼り付けます。

Imports System
Imports System.Drawing
Imports System.Windows.Forms

Class Form1
    Inherits Form

    Private  BindingSource1 As New
 BindingSource()
    Private textBox1 As New
 TextBox()
    Private textBox2 As New
 TextBox()
    Private textBox3 As New
 TextBox()

    Public Sub New()

        'Set up the textbox controls.
        Me.textBox1.Location = New System.Drawing.Point(82,
 13)
        Me.textBox1.TabIndex = 1
        Me.textBox2.Location = New System.Drawing.Point(81,
 47)
        Me.textBox2.TabIndex = 2
        Me.textBox3.Location = New System.Drawing.Point(81,
 83)
        Me.textBox3.TabIndex = 3

        ' Add the textbox controls to the form
        Me.Controls.Add(Me.textBox2)
        Me.Controls.Add(Me.textBox1)
        Me.Controls.Add(Me.textBox3)

    End Sub

    Private WithEvents partNameBinding As
 Binding
    Private WithEvents partNumberBinding As
 Binding

    Private Sub Form1_Load(ByVal
 sender As Object, ByVal
 e As EventArgs) _
        Handles Me.Load

        ' Set the DataSource of BindingSource1 to the Part type.
        BindingSource1.DataSource = GetType(Part)

        ' Bind the textboxes to the properties of the Part type, 
        ' enabling formatting.
        partNameBinding = textBox1.DataBindings.Add("Text",
 BindingSource1, _
            "PartName", True)
        partNumberBinding = textBox2.DataBindings.Add("Text",
 BindingSource1, _
            "PartNumber", True)
        
        'Bind the textbox to the PartPrice value with currency formatting.
        textBox3.DataBindings.Add("Text", BindingSource1,
 "PartPrice", _
            True, DataSourceUpdateMode.OnPropertyChanged, 0, "C")

        ' Add a new part to BindingSource1.
        BindingSource1.Add(New Part("Widget",
 1234, 12.45))
    End Sub

    ' Handle the BindingComplete event to catch errors and exceptions
 
    ' in binding process.
    Sub partNumberBinding_BindingComplete(ByVal
 sender As Object, _
        ByVal e As BindingCompleteEventArgs)
 _
        Handles partNumberBinding.BindingComplete

        If Not e.BindingCompleteState = BindingCompleteState.Success
 Then
            MessageBox.Show("partNumberBinding: "
 + e.ErrorText)
        End If

    End Sub

    ' Handle the BindingComplete event to catch errors and exceptions
 
    ' in binding process.
    Sub partNameBinding_BindingComplete(ByVal
 sender As Object, _
        ByVal e As BindingCompleteEventArgs)
 _
        Handles partNameBinding.BindingComplete

        If Not e.BindingCompleteState = BindingCompleteState.Success
 Then
            MessageBox.Show("partNameBinding: " +
 e.ErrorText)
        End If
       
    End Sub

    <STAThread()> _
    Shared Sub Main()
        Application.EnableVisualStyles()
        Application.Run(New Form1())
    End Sub

End Class

' Represents a business object that throws exceptions when invalid 
' values are entered for some of its properties.
Public Class Part
    Private name As String
    Private number As Integer
    Private price As Double

    Public Sub New(ByVal
 name As String, ByVal
 number As Integer, _
        ByVal price As Double)

        PartName = name
        PartNumber = number
        PartPrice = price
    End Sub


    Public Property PartName() As
 String
        Get
            Return name
        End Get
        Set(ByVal value As
 String)
            If Value.Length <= 0 Then
                Throw New Exception("Each
 part must have a name.")
            Else
                name = Value
            End If
        End Set
    End Property

    Public Property PartPrice() As
 Double
        Get
            Return price
        End Get
        Set(ByVal value As
 Double)
            price = Value
        End Set
    End Property

    Public Property PartNumber() As
 Integer
        Get
            Return number
        End Get
        Set(ByVal value As
 Integer)
            If Value < 100 Then
                Throw New Exception("Invalid
 part number." _
                    & " Part numbers must be greater than
 100.")
            Else
                number = Value
            End If
        End Set
    End Property
End Class
using System;
using System.Drawing;
using System.Windows.Forms;

class Form1 : Form
{
    private BindingSource BindingSource1 = new
 BindingSource();
    private TextBox textBox1 = new TextBox();
    private TextBox textBox2 = new TextBox();
    private TextBox textBox3 = new TextBox();

    public Form1()
    {
        //Set up the textbox controls.
        this.textBox1.Location = new System.Drawing.Point(82,
 13);
        this.textBox1.TabIndex = 1;
        this.textBox2.Location = new System.Drawing.Point(81,
 47);
        this.textBox2.TabIndex = 2;
        this.textBox3.Location = new System.Drawing.Point(81,
 83);
        this.textBox3.TabIndex = 3;

        // Add the textbox controls to the form
        this.Controls.Add(this.textBox2);
        this.Controls.Add(this.textBox1);
        this.Controls.Add(this.textBox3);

        // Handle the form's Load event.
        this.Load += new System.EventHandler(this.Form1_Load);
    }
    Binding partNameBinding;
    Binding partNumberBinding;

    private void Form1_Load(object sender,
 EventArgs e)
    {
        // Set the DataSource of BindingSource1 to the Part type.
        BindingSource1.DataSource = typeof(Part);

        // Bind the textboxes to the properties of the Part type, 
        // enabling formatting.
        partNameBinding = textBox1.DataBindings.Add("Text",
            BindingSource1, "PartName", true);
        
        partNumberBinding = textBox2.DataBindings.Add("Text", BindingSource1,
 "PartNumber",
            true);

        //Bind the textbox to the PartPrice value with currency formatting.
        textBox3.DataBindings.Add("Text", BindingSource1, "PartPrice",
 true,
            DataSourceUpdateMode.OnPropertyChanged, 0, "C");
            

        // Handle the BindingComplete event for BindingSource1 and 
        // the partNameBinding.
        partNumberBinding.BindingComplete +=
            new BindingCompleteEventHandler(partNumberBinding_BindingComplete);
        partNameBinding.BindingComplete +=
            new BindingCompleteEventHandler(partNameBinding_BindingComplete);

        // Add a new part to BindingSource1.
        BindingSource1.Add(new Part("Widget", 1234,
 12.45));
    }

    // Handle the BindingComplete event to catch errors and exceptions
 
    // in binding process.
    void partNumberBinding_BindingComplete(object sender,
        BindingCompleteEventArgs e)
    {
        if (e.BindingCompleteState != BindingCompleteState.Success)
            MessageBox.Show("partNumberBinding: " + e.ErrorText);
    }        

    // Handle the BindingComplete event to catch errors and 
    // exceptions in binding process.
    void partNameBinding_BindingComplete(object sender,
        BindingCompleteEventArgs e)
    {
        if (e.BindingCompleteState != BindingCompleteState.Success)
            MessageBox.Show("partNameBinding: " + e.ErrorText);
    }

    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.Run(new Form1());
    }
}

// Represents a business object that throws exceptions when invalid
 values are
// entered for some of its properties.
public class Part
{
    private string name;
    private int number;
    private double price;

    public Part(string name, int
 number, double price)
    {
        PartName = name;
        PartNumber = number;
        PartPrice = price;
    }

    public string PartName
    {
        get { return name; }
        set
        {
            if (value.Length <= 0)
                throw new Exception("Each part must have
 a name.");
            else
                name = value;
        }
    }
    public double PartPrice
    {
        get { return price; }
        set { price = value; }
    }

    public int PartNumber
    {
        get { return number; }
        set
        {
            if (value < 100)
                throw new Exception("Invalid part number."
 +
                    " Part numbers must be greater than 100.");
            else
                number = value;
        }
    }
}
// Represents a business object that throws exceptions when 
// invalid values are entered for some of its properties.
public ref class Part
{
private:
    String^ name;
    int number;
    double price;

public:
    Part(String^ name, int number, double price)
    {
        PartName = name;
        PartNumber = number;
        PartPrice = price;
    }

    property String^ PartName 
    {
        String^ get()
        {
            return name;
        }

        void set(String^ value)
        {
            if (value->Length <= 0)
            {
                throw gcnew Exception(
                    "Each part must have a name.");
            }
            else
            {
                name = value;
            }
        }
    }

    property double PartPrice 
    {
        double get()
        {
            return price;
        }

        void set(double value)
        {
            price = value;
        }
    }

    property int PartNumber 
    {
        int get()
        {
            return number;
        }

        void set(int value)
        {
            if (value < 100)
            {
                throw gcnew Exception(
                    "Invalid part number." \
                    "Part numbers must be " \
                    "greater than 100.");
            }
            else
            {
                number = value;
            }
        }
    }

};

ref class MainForm: public Form
{
private:
    BindingSource^ bindingSource;
    TextBox^ partNameTextBox;
    TextBox^ partNumberTextBox;
    TextBox^ partPriceTextBox;

public:
    MainForm()
    {
        bindingSource = gcnew BindingSource;
        partNameTextBox = gcnew TextBox;
        partNumberTextBox = gcnew TextBox;
        partPriceTextBox = gcnew TextBox;
            
        //Set up the textbox controls.
        this->partNameTextBox->Location = Point(82, 13);
        this->partNameTextBox->TabIndex = 1;
        this->partNumberTextBox->Location = Point(81, 47);
        this->partNumberTextBox->TabIndex = 2;
        this->partPriceTextBox->Location = Point(81, 83);
        this->partPriceTextBox->TabIndex = 3;
        
        // Add the textbox controls to the form
        this->Controls->Add(this->partNumberTextBox);
        this->Controls->Add(this->partNameTextBox);
        this->Controls->Add(this->partPriceTextBox);
        
        // Handle the form's Load event.
        this->Load += gcnew EventHandler(this,
 
            &MainForm::OnMainFormLoad);
    }

private:

    void OnMainFormLoad(Object^ sender, EventArgs^ e)
    {   
        // Set the DataSource of bindingSource to the Part type.
        bindingSource->DataSource = Part::typeid;
        
        // Bind the textboxes to the properties of the Part type,
        // enabling formatting.
        partNameTextBox->DataBindings->Add(
            "Text", bindingSource, "PartName", true);
        partNumberTextBox->DataBindings->Add(
            "Text", bindingSource, "PartNumber", true);
        
        //Bind the textbox to the PartPrice value 
        // with currency formatting.
        partPriceTextBox->DataBindings->Add("Text", bindingSource,
 "PartPrice", true,
           DataSourceUpdateMode::OnPropertyChanged, nullptr, "C");

        // Handle the BindingComplete event for bindingSource and
        // the partNameBinding.
        bindingSource->BindingComplete += 
            gcnew BindingCompleteEventHandler(this, 
            &MainForm::OnBindingSourceBindingComplete);
        bindingSource->BindingComplete += 
            gcnew BindingCompleteEventHandler(this, 
            &MainForm::OnPartNameBindingBindingComplete);
        
        // Add a new part to bindingSource.
        bindingSource->Add(gcnew Part("Widget", 1234, 12.45));
    }

    // Handle the BindingComplete event to catch errors and 
    // exceptions in binding process.
    void OnBindingSourceBindingComplete(Object^ sender, 
        BindingCompleteEventArgs^ e)
    {
        if (e->BindingCompleteState == 
            BindingCompleteState::Exception)
        {
            MessageBox::Show(String::Format(
                CultureInfo::CurrentCulture,
                "bindingSource: {0}", e->Exception->Message));
        }

        if (e->BindingCompleteState == 
            BindingCompleteState::DataError)
        {
            MessageBox::Show(String::Format(
                CultureInfo::CurrentCulture,
                "bindingSource: {0}", e->Exception->Message));
        }
    }

    // Handle the BindingComplete event to catch errors and 
    // exceptions in binding process.
    void OnPartNameBindingBindingComplete(Object^ sender, 
        BindingCompleteEventArgs^ e)
    {
        if (e->BindingCompleteState == 
            BindingCompleteState::Exception)
        {
            MessageBox::Show(String::Format(
                CultureInfo::CurrentCulture,
                "PartNameBinding: {0}", e->Exception->Message));
        }

        if (e->BindingCompleteState == 
            BindingCompleteState::DataError)
        {
            MessageBox::Show(String::Format(
                CultureInfo::CurrentCulture,
                "PartNameBinding: {0}", e->Exception->Message));
        }
    }
};

継承階層継承階層
System.Object
   System.EventArgs
     System.ComponentModel.CancelEventArgs
      System.Windows.Forms.BindingCompleteEventArgs
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

BindingCompleteEventArgs コンストラクタ (Binding, BindingCompleteState, BindingCompleteContext)

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

バインディング、エラー状態、およびバインディング コンテキストを指定して BindingCompleteEventArgs クラスの新しいインスタンスを初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Sub New ( _
    binding As Binding, _
    state As BindingCompleteState, _
    context As BindingCompleteContext _
)
Dim binding As Binding
Dim state As BindingCompleteState
Dim context As BindingCompleteContext

Dim instance As New BindingCompleteEventArgs(binding,
 state, context)
public BindingCompleteEventArgs (
    Binding binding,
    BindingCompleteState state,
    BindingCompleteContext context
)
public:
BindingCompleteEventArgs (
    Binding^ binding, 
    BindingCompleteState state, 
    BindingCompleteContext context
)
public BindingCompleteEventArgs (
    Binding binding, 
    BindingCompleteState state, 
    BindingCompleteContext context
)
public function BindingCompleteEventArgs (
    binding : Binding, 
    state : BindingCompleteState, 
    context : BindingCompleteContext
)

パラメータ

binding

この BindingComplete イベントに関連するバインディング。

state

BindingCompleteState 値の 1 つ。

context

BindingCompleteContext 値の 1 つ。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BindingCompleteEventArgs クラス
BindingCompleteEventArgs メンバ
System.Windows.Forms 名前空間

BindingCompleteEventArgs コンストラクタ (Binding, BindingCompleteState, BindingCompleteContext, String)

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

バインディング、エラー状態とエラー テキスト、およびバインディング コンテキストを指定して BindingCompleteEventArgs クラスの新しいインスタンスを初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Sub New ( _
    binding As Binding, _
    state As BindingCompleteState, _
    context As BindingCompleteContext, _
    errorText As String _
)
Dim binding As Binding
Dim state As BindingCompleteState
Dim context As BindingCompleteContext
Dim errorText As String

Dim instance As New BindingCompleteEventArgs(binding,
 state, context, errorText)
public BindingCompleteEventArgs (
    Binding binding,
    BindingCompleteState state,
    BindingCompleteContext context,
    string errorText
)
public:
BindingCompleteEventArgs (
    Binding^ binding, 
    BindingCompleteState state, 
    BindingCompleteContext context, 
    String^ errorText
)
public BindingCompleteEventArgs (
    Binding binding, 
    BindingCompleteState state, 
    BindingCompleteContext context, 
    String errorText
)
public function BindingCompleteEventArgs (
    binding : Binding, 
    state : BindingCompleteState, 
    context : BindingCompleteContext, 
    errorText : String
)

パラメータ

binding

この BindingComplete イベントに関連するバインディング。

state

BindingCompleteState 値の 1 つ。

context

BindingCompleteContext 値の 1 つ。

errorText

バインディング時に発生したエラーのエラー テキストまたは例外メッセージ。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BindingCompleteEventArgs クラス
BindingCompleteEventArgs メンバ
System.Windows.Forms 名前空間

BindingCompleteEventArgs コンストラクタ (Binding, BindingCompleteState, BindingCompleteContext, String, Exception)

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

バインディング、エラー状態とエラー テキスト、バインディング コンテキスト、および例外を指定して BindingCompleteEventArgs クラスの新しいインスタンスを初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Sub New ( _
    binding As Binding, _
    state As BindingCompleteState, _
    context As BindingCompleteContext, _
    errorText As String, _
    exception As Exception _
)
Dim binding As Binding
Dim state As BindingCompleteState
Dim context As BindingCompleteContext
Dim errorText As String
Dim exception As Exception

Dim instance As New BindingCompleteEventArgs(binding,
 state, context, errorText, exception)
public BindingCompleteEventArgs (
    Binding binding,
    BindingCompleteState state,
    BindingCompleteContext context,
    string errorText,
    Exception exception
)
public:
BindingCompleteEventArgs (
    Binding^ binding, 
    BindingCompleteState state, 
    BindingCompleteContext context, 
    String^ errorText, 
    Exception^ exception
)
public BindingCompleteEventArgs (
    Binding binding, 
    BindingCompleteState state, 
    BindingCompleteContext context, 
    String errorText, 
    Exception exception
)
public function BindingCompleteEventArgs (
    binding : Binding, 
    state : BindingCompleteState, 
    context : BindingCompleteContext, 
    errorText : String, 
    exception : Exception
)

パラメータ

binding

この BindingComplete イベントに関連するバインディング。

state

BindingCompleteState 値の 1 つ。

context

BindingCompleteContext 値の 1 つ。

errorText

バインディング時に発生したエラーのエラー テキストまたは例外メッセージ。

exception

バインディング時に発生した Exception。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BindingCompleteEventArgs クラス
BindingCompleteEventArgs メンバ
System.Windows.Forms 名前空間

BindingCompleteEventArgs コンストラクタ (Binding, BindingCompleteState, BindingCompleteContext, String, Exception, Boolean)

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

バインディング、エラー状態およびエラー テキスト、バインディング コンテキスト、例外、およびバインディングをキャンセルするかどうかを指定して、BindingCompleteEventArgs クラスの新しいインスタンスを初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Sub New ( _
    binding As Binding, _
    state As BindingCompleteState, _
    context As BindingCompleteContext, _
    errorText As String, _
    exception As Exception, _
    cancel As Boolean _
)
Dim binding As Binding
Dim state As BindingCompleteState
Dim context As BindingCompleteContext
Dim errorText As String
Dim exception As Exception
Dim cancel As Boolean

Dim instance As New BindingCompleteEventArgs(binding,
 state, context, errorText, exception, cancel)
public BindingCompleteEventArgs (
    Binding binding,
    BindingCompleteState state,
    BindingCompleteContext context,
    string errorText,
    Exception exception,
    bool cancel
)
public:
BindingCompleteEventArgs (
    Binding^ binding, 
    BindingCompleteState state, 
    BindingCompleteContext context, 
    String^ errorText, 
    Exception^ exception, 
    bool cancel
)
public BindingCompleteEventArgs (
    Binding binding, 
    BindingCompleteState state, 
    BindingCompleteContext context, 
    String errorText, 
    Exception exception, 
    boolean cancel
)
public function BindingCompleteEventArgs (
    binding : Binding, 
    state : BindingCompleteState, 
    context : BindingCompleteContext, 
    errorText : String, 
    exception : Exception, 
    cancel : boolean
)

パラメータ

binding

この BindingComplete イベントに関連するバインディング。

state

BindingCompleteState 値の 1 つ。

context

BindingCompleteContext 値の 1 つ。

errorText

バインディング時に発生したエラーのエラー テキストまたは例外メッセージ。

exception

バインディング時に発生した Exception。

cancel

バンディングをキャンセルして現在のコントロールにフォーカスを維持する場合は true。他のコントロールにフォーカスを移動できるようにする場合は false。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BindingCompleteEventArgs クラス
BindingCompleteEventArgs メンバ
System.Windows.Forms 名前空間

BindingCompleteEventArgs コンストラクタ

BindingCompleteEventArgs クラスの新しいインスタンスを初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
BindingCompleteEventArgs (Binding, BindingCompleteState, BindingCompleteContext) バインディング、エラー状態、およびバインディング コンテキストを指定して BindingCompleteEventArgs クラスの新しいインスタンスを初期化します。

.NET Compact Framework によってサポートされています。

BindingCompleteEventArgs (Binding, BindingCompleteState, BindingCompleteContext, String) バインディング、エラー状態とエラー テキスト、およびバインディング コンテキストを指定して BindingCompleteEventArgs クラスの新しいインスタンスを初期化します。

.NET Compact Framework によってサポートされています。

BindingCompleteEventArgs (Binding, BindingCompleteState, BindingCompleteContext, String, Exception) バインディング、エラー状態とエラー テキスト、バインディング コンテキスト、および例外を指定して BindingCompleteEventArgs クラスの新しいインスタンスを初期化します。

.NET Compact Framework によってサポートされています。

BindingCompleteEventArgs (Binding, BindingCompleteState, BindingCompleteContext, String, Exception, Boolean) バインディング、エラー状態およびエラー テキスト、バインディング コンテキスト、例外、およびバインディングをキャンセルするかどうかを指定して、BindingCompleteEventArgs クラスの新しいインスタンスを初期化します。

.NET Compact Framework によってサポートされています。

参照参照

関連項目

BindingCompleteEventArgs クラス
BindingCompleteEventArgs メンバ
System.Windows.Forms 名前空間

BindingCompleteEventArgs プロパティ


BindingCompleteEventArgs メソッド


BindingCompleteEventArgs メンバ

BindingComplete イベントのデータを提供します。

BindingCompleteEventArgs データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド BindingCompleteEventArgs オーバーロードされます。 BindingCompleteEventArgs クラスの新しいインスタンスを初期化します。
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

BindingCompleteEventArgs クラス
System.Windows.Forms 名前空間



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「BindingCompleteEventArgs」の関連用語

BindingCompleteEventArgsのお隣キーワード

   

英語⇒日本語
日本語⇒英語
   



BindingCompleteEventArgsのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS