gpt4 book ai didi

c# - 如何在报表中使用表单控件属性?

转载 作者:搜寻专家 更新时间:2023-10-30 23:43:41 26 4
gpt4 key购买 nike

我正在尝试为学校管理系统开发一个简单的数据库前端,我正在使用 ReportViewer 来显示报告中的一些数据,但是我想在报告中显示一些不在数据库,但在 UI 中作为用户输入(想想 myTextBox.Text)!如何才能做到这一点 ?

哦,我的 ReportViewer 与我想使用的用户输入字段采用不同的形式,让两个形式一起通信没有问题,但是如何从其中一个形式获取数据(控制属性)到报告中!

我使用的是 Visual Studio 2013,C#,数据库是 MS Access .accdb。

谢谢。

最佳答案

如果我理解你的问题是正确的:你首先将用户带到一个带有一些输入控件的页面。当他/她输入一个值并提交表单时,您将用户重定向到一个报告页面,该页面将显示用户输入的数据以及从数据库中提取的其他数据。如果这是真的,这就是我对你的帮助:

You can pass information between pages in various ways, some of which depend on how the redirection occurs. The following options are available even if the source page is in a different ASP.NET Web application from the target page, or if the source page is not an ASP.NET Web Forms page:

  • Use a query string.
  • Get HTTP POST information from the source page.

    The following options are available only when the source and target pages are in the same ASP.NET Web application.

    • Use session state.
    • Create public properties in the source page and access the property values in the target page.
    • Get control information in the target page from controls in the source page.

来源:https://msdn.microsoft.com/en-us/library/6c3yckfw.aspx

编辑:如果在 Windows 窗体上工作,以下内容可能会有所帮助。我通常不使用 WinForms,因此请查看源链接以获取更多详细信息:

在接收表单上创建一个方法来处理接收到的数据,如下所示:

internal void LoadCustomData(CustomClass customObject)  
{
// Update the local DataSet with the data in customObject
}

在输入表单上调用此方法并为接收表单调用 Show() 方法,如下所示:

private void customersDataGridView_DoubleClick(object sender, EventArgs e)
{
// Get data from the input control
CustomObject data;

// Pass the data to receiving form
ReceivingForm reportForm = new ReceivingForm();
reportForm.LoadCustomData(data);
reportForm.Show();
}

来源:https://msdn.microsoft.com/en-us/library/ms171925.aspx

关于c# - 如何在报表中使用表单控件属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31865782/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com