如何使多个参数多于两个? CustomButtonClickEventArgs是很多地方共享的,我不想修改。如何附加ActiveRow和ActiveCol参数,这些参数将Grid中的ComboBox位置指向ComboBoxCustomButtonClick事件,就像我预期的那样?
private void MyUC1_ComboBoxCustomButtonClick(object sender, MyUC.CustomButtonClickEventArgs e, int ActiveRow, int ActiveCol)
声明:
public class CustomButtonClickEventArgs : EventArgs
{
public readonly int Index;
public readonly string Key;
public readonly string Tag;
public readonly Keys ModifierKeys;
public CustomButtonClickEventArgs(int index, string key, string tag, Keys modifierKeys)
{
this.Index = index;
this.Key = key;
this.Tag = tag;
this.ModifierKeys = modifierKeys;
}
}
public delegate void CustomButtonClickEventHandler(object sender, CustomButtonClickEventArgs e);
答案 0 :(得分:2)
您刚刚定义了事件参数(EventArgs)。您需要的是一个委托,它定义了该方法的外观。
也许是这样的?
public delegate void CustomButtonClickEventHandler(object sender, MyUC.CustomButtonClickEventArgs e, int ActiveRow, int ActiveCol);
定义事件时,需要此委托:
public event CustomButtonClickEventHandler ComboBoxCustomButtonClick;
答案 1 :(得分:0)
我的新CustomButtonClickEventHandler定义如下。
public delegate void ComboBoxCustomButtonClickEventHandler(object Sender, int ComboBoxCol, int ActiveRow, int ActiveCol, CustomButtonClickEventArgs e);
[Category("ComboBox"), Description("Occurs when a custom button of the ComboBox is clicked.")]
public event ComboBoxCustomButtonClickEventHandler ComboBoxCustomButtonClick;