可恨的委托>"<
是偶太笨吗...委托的文章看过几篇,曾经实践过一个早上,也成功过。可过了1,2个月还是忘记,始终无法真正理解委托的意思! 真伤心,超级挫败!
比如两个同级的用户控件uc1和uc2, uc1_btnA的方法触发uc2_btnB的方法AddMatrixCallBackFunction
uc1:
// 实现一个事件
this.uc1_btnA.AddChick +=new uc2_btnB.AddMatrixEventHandler(this.AddMatrixCallBackFunction);
uc2:
// 定义委托
public delegate void AddMatrixEventHandler();
![](/Images/OutliningIndicators/None.gif)
// 定义委托类型的事件
public event AddMatrixEventHandler AddChick;
![](/Images/OutliningIndicators/None.gif)
// 定义一个方法,指向此委托类型的事件
private void btnAddMatrix_Click(object sender, System.EventArgs e)
{
if (this.AddChick!=null)
{
this.AddChick();
}
}
偶笨笨的脑袋实在无法理解T。T help
比如两个同级的用户控件uc1和uc2, uc1_btnA的方法触发uc2_btnB的方法AddMatrixCallBackFunction
uc1:
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
uc2:
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
![](/Images/OutliningIndicators/None.gif)
偶笨笨的脑袋实在无法理解T。T help
愿一路奔跑不退缩,到目前一直从事.Net的B/S,C/S企业应用研发