Parameter.OnParameterChanged メソッド

定義

OnParametersChanged(EventArgs) オブジェクトを含むParameterCollection コレクションのParameter メソッドを呼び出します。

protected:
 void OnParameterChanged();
protected void OnParameterChanged();
member this.OnParameterChanged : unit -> unit
Protected Sub OnParameterChanged ()

次のコード例では、パラメーターの状態が変化したときに OnParameterChanged メソッドを呼び出して ParametersChanged イベントを発生させる方法を示します。 このコード例は、 Parameter クラスの概要に関するより大きな例の一部です。

// The Value property is a type safe convenience property
// used when the StaticParameter represents string data.
// It gets the string value of the DataValue property, and
// sets the DataValue property directly.
public string Value {
  get {
    object o = DataValue;
    if (o == null || !(o is string))
      return String.Empty;
    return (string)o;
  }
  set {
    DataValue = value;
    OnParameterChanged();
  }
}
' The Value property is a type safe convenience property
' used when the StaticParameter represents string data.
' It gets the string value of the DataValue property, and
' sets the DataValue property directly.
Public Property Value() As String
   Get
      Dim o As Object = DataValue
      If o Is Nothing OrElse Not TypeOf o Is String Then
         Return String.Empty
      End If
      Return CStr(o)
   End Get
   Set
      DataValue = value
      OnParameterChanged()
   End Set
End Property

注釈

Parameter オブジェクトがParameterCollection コレクションに含まれていない場合、OnParameterChanged メソッドを呼び出しても効果はありません。 Parameter オブジェクトがParameterCollection コレクションに含まれている場合、OnParameterChangedはコレクションのParameterCollection.ParametersChanged イベントを発生させます。

ParameterCollection コレクションがデータ ソース コントロールに含まれている場合、ParameterCollection.ParametersChanged イベントによってデータ ソース コントロールのDataSourceChanged イベントが発生し、データ バインド コントロールが再バインドされます。

イベントを発生させると、デリゲートを介してイベント ハンドラーが呼び出されます。 詳細については、「イベントの 処理と発生」を参照してください。

OnParameterChanged メソッドでは、デリゲートをアタッチせずに、派生クラスでイベントを処理することもできます。 これは、派生クラスでイベントを処理するために推奨される手法です。

注意 (継承者)

派生クラスで OnParameterChanged() をオーバーライドする場合は、登録されているデリゲートがイベントを受け取るように、基底クラスの OnParameterChanged() メソッドを必ず呼び出してください。

適用対象

こちらもご覧ください