BindingCompleteEventArgs Class
Provides data for the BindingComplete event.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
System::EventArgs
System.ComponentModel::CancelEventArgs
System.Windows.Forms::BindingCompleteEventArgs
| Name | Description | |
|---|---|---|
![]() | BindingCompleteEventArgs(Binding^, BindingCompleteState, BindingCompleteContext) | Initializes a new instance of the BindingCompleteEventArgs class with the specified binding, error state, and binding context. |
![]() | BindingCompleteEventArgs(Binding^, BindingCompleteState, BindingCompleteContext, String^) | Initializes a new instance of the BindingCompleteEventArgs class with the specified binding, error state and text, and binding context. |
![]() | BindingCompleteEventArgs(Binding^, BindingCompleteState, BindingCompleteContext, String^, Exception^) | Initializes a new instance of the BindingCompleteEventArgs class with the specified binding, error state and text, binding context, and exception. |
![]() | BindingCompleteEventArgs(Binding^, BindingCompleteState, BindingCompleteContext, String^, Exception^, Boolean) | Initializes a new instance of the BindingCompleteEventArgs class with the specified binding, error state and text, binding context, exception, and whether the binding should be cancelled. |
| Name | Description | |
|---|---|---|
![]() | Binding | Gets the binding associated with this occurrence of a BindingComplete event. |
![]() | BindingCompleteContext | Gets the direction of the binding operation. |
![]() | BindingCompleteState | Gets the completion state of the binding operation. |
![]() | Cancel | Gets or sets a value indicating whether the event should be canceled.(Inherited from CancelEventArgs.) |
![]() | ErrorText | Gets the text description of the error that occurred during the binding operation. |
![]() | Exception | Gets the exception that occurred during the binding operation. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object^) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | Finalize() | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.) |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | MemberwiseClone() | |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
The BindingCompleteEventArgs contains information regarding exceptions or errors that occurred during a binding process.
The following code example demonstrates handling the BindingComplete event. To run this code, paste it into an empty code file.
// 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)); } } };
Available since 2.0
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


