我有一個DataGrid
和ContextMenuStrip
在裏面。當我連續點擊SelectMenuStrip
時,我希望ClickEvent
的上下文菜單可以獲得databean
類中該行中的所有數據,並返回該類,以便我可以將數據填充到另一個類中 - 一切正常我定義的事件如下ToolStripMenuItem click event should return a class
private CustomerDataBean toolStripMenuItem1_Click(object sender, EventArgs e)
{
CustomerDataBean custdatabean = null;
int rowno = tblcustomerdataview.CurrentCellAddress.Y;
custdatabean.Customerpk = int.Parse(tblcustomerdataview.Rows[rowno].Cells[0].Value.ToString());
custdatabean.Contactno = tblcustomerdataview.Rows[rowno].Cells[6].Value.ToString();
custdatabean.Emailid = tblcustomerdataview.Rows[rowno].Cells[7].Value.ToString();
custdatabean.Other = tblcustomerdataview.Rows[rowno].Cells[8].Value.ToString();
return custdatabean;
}
但designer.cs
我本着得到一個錯誤:
this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click);
的錯誤是:
Error 1:
'WindowsFormsApplication3.CustomerDataBean WindowsFormsApplication3.CustomerSearch.toolStripMenuItem1_Click(object, System.EventArgs)' has the wrong return type D:\WindowsFormsApplication3\WindowsFormsApplication3\Merchandising\customerSearch.Designer.cs 83 46 NFTRANS
我在哪裏做錯了什麼? 讓我解釋一下情況 我有一個jobcodeform,用戶應該在combobox中輸入客戶代碼,如果他忘記了客戶代碼,他可以使用buton去另一個叫customersearch的表單,其中有一個帶有上下文菜單欄的datagrid表, customerDatabean中所選行的全部細節,並將其返回到第一個作業代碼表
系統事件沒有返回任何內容,因爲這意味着你想返回類到windows。你想在哪裏退貨? ----------'MouseEventHandler'是一個'delegate',它只是帶有兩個參數的void方法。你不能向委託中添加不同的方法,並希望工作正常。 ----------你爲什麼不叫一個方法,在那裏做你的作品? – 2012-02-17 19:49:10
標準事件返回'void',因爲它們是多播的。 – 2012-02-17 19:56:11
@HenkHolterman:但它認爲原因是該方法返回到'system'而不是返回代碼。 – 2012-02-17 20:01:08