c# 怎么让textbox触发Validating

如我有10个textbox,其中5个绑定了Validating事件,我现在想点击按钮手动触发这10个按钮。我用foreach遍历,想实现,如果当前textbox绑定了Validating事件,则触发这个事件,没有绑定则不管他。该怎么实现?

搜到的,如何判断方法是否已有事件绑定:

public bool IsEventHandlerRegistered(Delegate prospectiveHandler){   
    if ( this.EventHandler != null )
    {
        foreach ( Delegate existingHandler in this.EventHandler.GetInvocationList() )
        {
            if ( existingHandler == prospectiveHandler )
            {
                return true;
            }
        }
    }
    return false;}

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答