1.定义变量
private string inNewstoc="";
public string InNewstoc
{
get { return inNewstoc; }
set
{
if (inNewstoc != value)
{
// 触发事件
InValueChanged?.Invoke(this, value);
}
inNewstoc = value;
}
}
2.定义委托
public delegate void ValueChangedEventHandler(object sender, string newValue);
3.定义事件
public event ValueChangedEventHandler InValueChanged;
4. // 事件处理方法
private void OnInValueChanged(object sender, string newValue)
{
if (!newValue.Equals("Y"))
{
this.Column27.Visible = false;
}
else
{
this.Column27.Visible = true;
}
}
5.订阅事件
InValueChanged += OnInValueChanged;