Parameter.OnParameterChanged 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
调用包含 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() 委托接收事件。