如何准确传递输入参数至C语言函数?
- 内容介绍
- 文章标签
- 相关推荐
本文共计497个文字,预计阅读时间需要2分钟。
我向往自由的生活,渴望摆脱束缚,追求真实自我。
我是C#和.NET的新手,我有以下问题.在我的代码中,我有这样的事情:
Table table = new Table(); lstLabelType.SelectedIndexChanged += new System.EventHandler(SelectDocumentTypeChanged);
将事件处理程序附加到视图中的下拉元素.
因此,当用户将所选值更改为此下拉列表时,将执行SelectDocumentTypeChanged()方法,此方法:
private void SelectDocumentTypeChanged(object sender, EventArgs e) { Debug.WriteLine("SelectDocumentTypeChanged() STARTED"); SPWeb contextWeb = SPContext.Current.Web; DropDownList listaTipiDocumenti = (DropDownList)sender; tipoDocumentoSelezionato = listaTipiDocumenti.SelectedValue; this.renderizzaEtichetteFacoltative(tipoDocumentoSelezionato, table); string url = contextWeb.Url; string link = url + "/ARXEIA WEBPART/Stampa Etichetta.aspx?IsDlg=1&postazione=" + macchina + "&tipoDoc=" + tipoDocumentoSelezionato; SPUtility.Redirect(link, SPRedirectFlags.Default, Context); }
现在我有一个问题.我必须将在我的代码中创建的Table表对象传递给此事件处理程序方法,因为在此方法中我必须使用它.
我该如何正确实现此行为?当用户更改下拉列表中的值时,如何自动调用此Table表对象到SelectDocumentTypeChanged()方法?
尝试编写如下代码:Table table = new Table(); lstLabelType.SelectedIndexChanged += (sender, e) => { Debug.WriteLine("SelectDocumentTypeChanged() STARTED"); SPWeb contextWeb = SPContext.Current.Web; DropDownList listaTipiDocumenti = (DropDownList)sender; tipoDocumentoSelezionato = listaTipiDocumenti.SelectedValue; this.renderizzaEtichetteFacoltative(tipoDocumentoSelezionato, table); string url = contextWeb.Url; string link = url + "/ARXEIA WEBPART/Stampa Etichetta.aspx?IsDlg=1&postazione=" + macchina + "&tipoDoc=" + tipoDocumentoSelezionato; SPUtility.Redirect(link, SPRedirectFlags.Default, Context); };
现在您可以直接在事件处理程序中使用表.
您甚至可以立即忽略发件人并执行此操作:
lstLabelType.SelectedIndexChanged += (s, e) => { Debug.WriteLine("SelectDocumentTypeChanged() STARTED"); SPWeb contextWeb = SPContext.Current.Web; tipoDocumentoSelezionato = lstLabelType.SelectedValue; this.renderizzaEtichetteFacoltative(tipoDocumentoSelezionato, table); string url = contextWeb.Url; string link = url + "/ARXEIA WEBPART/Stampa Etichetta.aspx?IsDlg=1&postazione=" + macchina + "&tipoDoc=" + tipoDocumentoSelezionato; SPUtility.Redirect(link, SPRedirectFlags.Default, Context); };
如果要保留单独的方法,可以执行此操作:
Table table = new Table(); lstLabelType.SelectedIndexChanged += (o, e) => SelectDocumentTypeChanged(lstLabelType, table); private void SelectDocumentTypeChanged(DropDownList lstLabelType, Table table) { Debug.WriteLine("SelectDocumentTypeChanged() STARTED"); SPWeb contextWeb = SPContext.Current.Web; tipoDocumentoSelezionato = lstLabelType.SelectedValue; this.renderizzaEtichetteFacoltative(tipoDocumentoSelezionato, table); string url = contextWeb.Url; string link = url + "/ARXEIA WEBPART/Stampa Etichetta.aspx?IsDlg=1&postazione=" + macchina + "&tipoDoc=" + tipoDocumentoSelezionato; SPUtility.Redirect(link, SPRedirectFlags.Default, Context); }
本文共计497个文字,预计阅读时间需要2分钟。
我向往自由的生活,渴望摆脱束缚,追求真实自我。
我是C#和.NET的新手,我有以下问题.在我的代码中,我有这样的事情:
Table table = new Table(); lstLabelType.SelectedIndexChanged += new System.EventHandler(SelectDocumentTypeChanged);
将事件处理程序附加到视图中的下拉元素.
因此,当用户将所选值更改为此下拉列表时,将执行SelectDocumentTypeChanged()方法,此方法:
private void SelectDocumentTypeChanged(object sender, EventArgs e) { Debug.WriteLine("SelectDocumentTypeChanged() STARTED"); SPWeb contextWeb = SPContext.Current.Web; DropDownList listaTipiDocumenti = (DropDownList)sender; tipoDocumentoSelezionato = listaTipiDocumenti.SelectedValue; this.renderizzaEtichetteFacoltative(tipoDocumentoSelezionato, table); string url = contextWeb.Url; string link = url + "/ARXEIA WEBPART/Stampa Etichetta.aspx?IsDlg=1&postazione=" + macchina + "&tipoDoc=" + tipoDocumentoSelezionato; SPUtility.Redirect(link, SPRedirectFlags.Default, Context); }
现在我有一个问题.我必须将在我的代码中创建的Table表对象传递给此事件处理程序方法,因为在此方法中我必须使用它.
我该如何正确实现此行为?当用户更改下拉列表中的值时,如何自动调用此Table表对象到SelectDocumentTypeChanged()方法?
尝试编写如下代码:Table table = new Table(); lstLabelType.SelectedIndexChanged += (sender, e) => { Debug.WriteLine("SelectDocumentTypeChanged() STARTED"); SPWeb contextWeb = SPContext.Current.Web; DropDownList listaTipiDocumenti = (DropDownList)sender; tipoDocumentoSelezionato = listaTipiDocumenti.SelectedValue; this.renderizzaEtichetteFacoltative(tipoDocumentoSelezionato, table); string url = contextWeb.Url; string link = url + "/ARXEIA WEBPART/Stampa Etichetta.aspx?IsDlg=1&postazione=" + macchina + "&tipoDoc=" + tipoDocumentoSelezionato; SPUtility.Redirect(link, SPRedirectFlags.Default, Context); };
现在您可以直接在事件处理程序中使用表.
您甚至可以立即忽略发件人并执行此操作:
lstLabelType.SelectedIndexChanged += (s, e) => { Debug.WriteLine("SelectDocumentTypeChanged() STARTED"); SPWeb contextWeb = SPContext.Current.Web; tipoDocumentoSelezionato = lstLabelType.SelectedValue; this.renderizzaEtichetteFacoltative(tipoDocumentoSelezionato, table); string url = contextWeb.Url; string link = url + "/ARXEIA WEBPART/Stampa Etichetta.aspx?IsDlg=1&postazione=" + macchina + "&tipoDoc=" + tipoDocumentoSelezionato; SPUtility.Redirect(link, SPRedirectFlags.Default, Context); };
如果要保留单独的方法,可以执行此操作:
Table table = new Table(); lstLabelType.SelectedIndexChanged += (o, e) => SelectDocumentTypeChanged(lstLabelType, table); private void SelectDocumentTypeChanged(DropDownList lstLabelType, Table table) { Debug.WriteLine("SelectDocumentTypeChanged() STARTED"); SPWeb contextWeb = SPContext.Current.Web; tipoDocumentoSelezionato = lstLabelType.SelectedValue; this.renderizzaEtichetteFacoltative(tipoDocumentoSelezionato, table); string url = contextWeb.Url; string link = url + "/ARXEIA WEBPART/Stampa Etichetta.aspx?IsDlg=1&postazione=" + macchina + "&tipoDoc=" + tipoDocumentoSelezionato; SPUtility.Redirect(link, SPRedirectFlags.Default, Context); }

