Страница: 1 |
|
Вопрос: reportviewer
|
Добавлено: 13.02.12 16:39
|
|
Автор вопроса: Nikos
|
c# как программно изменить значение textbox в reportviewer, а точнее в report.rdlc, чтоб можно было по нажатию кнопки менять этот textbox
Ответить
|
Номер ответа: 1 Автор ответа: SHDZ
ICQ: 209382104
Вопросов: 39 Ответов: 244
|
Профиль | | #1
|
Добавлено: 14.02.12 12:44
|
Один вариант это передавать параметр до построения отчета, но это тебе не нужно вот твое полотенце:
http://www.codeproject.com/Articles/15597/Using-the-ASP-NET-2-0-ReportViewer-in-Local-Mode
или с одного блога(сам прмер привести не погу, примерно помню как делал, сейчас глючит студия - не могу репорт создать):
-
- using System;
- 002 using System.Collections.Generic;
- 003 using System.ComponentModel;
- 004 using System.Data;
- 005 using System.Data.Common;
- 006 using System.Data.SqlClient;
- 007 using System.Drawing;
- 008 using System.Linq;
- 009 using System.Text;
- 010 using System.Windows.Forms;
- 011 using DataDynamics.ActiveReports;
- 012 using DataDynamics.ActiveReports.DataSources;
- 013 using DataDynamics.ActiveReports.Design;
- 014 using DataDynamics.ActiveReports.Document;
- 015 using DataDynamics.ActiveReports.Viewer;
- 016 using Microsoft.Reporting.WinForms;
- 017 using Microsoft.ReportingServices.ReportRendering;
- 018
- 019 namespace CustomerInfoReport
- 020 {
- 021 public partial class Form1 : Form
- 022 {
- 023 // declare variables
- 024 SqlDBDataSource myDataSource = new SqlDBDataSource();
- 025
- 026 public Form1()
- 027 {
- 028 InitializeComponent();
- 029
- 030 // create connection
- 031 myDataSource.ConnectionString = @"Data Source=NED-CREATIVE;initial catalog=C:\\SQL SERVER 2000 SAMPLE DATABASES\\NORTHWND.MDF;integrated security=SSPI;persist security info=False";
- 032 }
- 033
- 034 private void btnReport_Click(object sender, EventArgs e)
- 035 {
- 036 myDataSource.SQL = @"Select * from Employees";
- 037
- 038 ActiveReport3 myActiveReport = new ActiveReport3();
- 039
- 040 // header section
- 041 ReportHeader rHeader = new ReportHeader();
- 042 rHeader.Name = "pageHeader";
- 043 rHeader.BackColor = Color.Transparent;
- 044
- 045 myActiveReport.Sections.Add(rHeader);
- 046
- 047 // add controls to header section
- 048
- 049 // Title
- 050 DataDynamics.ActiveReports.Label label1 = new DataDynamics.ActiveReports.Label();
- 051 label1.Text = "Employees Address Report";
- 052 label1.Style = "font-weight: bold; font-size: 15.75pt;";
- 053 label1.Location = new PointF(2.31f, 0.13f);
- 054 rHeader.Controls.Add(label1);
- 055
- 056 // Date/Time
- 057 DataDynamics.ActiveReports.ReportInfo reportInfo1 = new DataDynamics.ActiveReports.ReportInfo();
- 058 reportInfo1.FormatString = "{RunDateTime:M/d/yyy}";
- 059 reportInfo1.Location = new PointF(0.06f, 0.19f);
- 060 rHeader.Controls.Add(reportInfo1);
- 061
- 062 // Page Number
- 063 DataDynamics.ActiveReports.ReportInfo reportInfo2 = new DataDynamics.ActiveReports.ReportInfo();
- 064 reportInfo2.FormatString = "Page {PageNumber} of {PageCount}";
- 065 reportInfo2.Location = new PointF(6.38f, 0.19f);
- 066 rHeader.Controls.Add(reportInfo2);
- 067
- 068 // Detail section
- 069 Detail myDetails = new Detail();
- 070 myDetails.Name = "pageDetail";
- 071 myActiveReport.Sections.Add(myDetails);
- 072
- 073 // add controls to detail section
- 074
- 075 // Last Name label
- 076 DataDynamics.ActiveReports.Label label2 = new DataDynamics.ActiveReports.Label();
- 077 label2.Text = "Last Name";
- 078 label2.Location = new PointF(0.06f, 0.06f);
- 079 myDetails.Controls.Add(label2);
- 080
- 081 // First Name label
- 082 DataDynamics.ActiveReports.Label label3 = new DataDynamics.ActiveReports.Label();
- 083 label3.Text = "First Name";
- 084 label3.Location = new PointF(1.13f, 0.06f);
- 085 myDetails.Controls.Add(label3);
- 086
- 087 // Address label
- 088 DataDynamics.ActiveReports.Label label4 = new DataDynamics.ActiveReports.Label();
- 089 label4.Text = "Address";
- 090 label4.Location = new PointF(2.44f, 0.06f);
- 091 myDetails.Controls.Add(label4);
- 092
- 093 // City label
- 094 DataDynamics.ActiveReports.Label label5 = new DataDynamics.ActiveReports.Label();
- 095 label5.Text = "City";
- 096 label5.Location = new PointF(4.56f, 0.06f);
- 097 myDetails.Controls.Add(label5);
- 098
- 099 // State label
- 100 DataDynamics.ActiveReports.Label label6 = new DataDynamics.ActiveReports.Label();
- 101 label6.Text = "State";
- 102 label6.Location = new PointF(5.69f, 0.06f);
- 103 myDetails.Controls.Add(label6);
- 104
- 105 //Last Name textbox
- 106 DataDynamics.ActiveReports.TextBox txtLastName1 = new DataDynamics.ActiveReports.TextBox();
- 107 txtLastName1.DataField = "LastName";
- 108 txtLastName1.Text = "txtLastName1";
- 109 txtLastName1.Location = new PointF(0.06f, 0.31f);
- 110 txtLastName1.Name = "txtLastName1";
- 111 myDetails.Controls.Add(txtLastName1);
- 112
- 113 DataDynamics.ActiveReports.TextBox txtFirstName1 = new DataDynamics.ActiveReports.TextBox();
- 114 txtFirstName1.DataField = "FirstName";
- 115 txtFirstName1.Text = "txtFirstName1";
- 116 txtFirstName1.Location = new PointF(1.13f, 0.31f);
- 117 txtFirstName1.Name = "txtFirstName1";
- 118 myDetails.Controls.Add(txtFirstName1);
- 119
- 120 DataDynamics.ActiveReports.TextBox txtAddress1 = new DataDynamics.ActiveReports.TextBox();
- 121 txtAddress1.DataField = "Address";
- 122 txtAddress1.Text = "txtAddress1";
- 123 txtAddress1.Location = new PointF(2.44f, 0.31f);
- 124 txtAddress1.Name = "txtAddress1";
- 125 myDetails.Controls.Add(txtAddress1);
- 126
- 127 DataDynamics.ActiveReports.TextBox txtCity1 = new DataDynamics.ActiveReports.TextBox();
- 128 txtCity1.DataField = "City";
- 129 txtCity1.Text = "txtCity1";
- 130 txtCity1.Location = new PointF(4.56f, 0.31f);
- 131 txtCity1.Name = "txtCity1";
- 132 myDetails.Controls.Add(txtCity1);
- 133
- 134 DataDynamics.ActiveReports.TextBox txtRegion1 = new DataDynamics.ActiveReports.TextBox();
- 135 txtRegion1.DataField = "Region";
- 136 txtRegion1.Text = "txtRegion1";
- 137 txtRegion1.Location = new PointF(5.69f, 0.31f);
- 138 txtRegion1.Name = "txtRegion1";
- 139 myDetails.Controls.Add(txtRegion1);
- 140
- 141 // corresponding footers.
- 142 ReportFooter myFooter = new ReportFooter();
- 143 myFooter.Name = "pageFooter";
- 144 myActiveReport.Sections.Add(myFooter);
- 145
- 146 // create DataTable with columns
- 147 DataTable myDataTable = new DataTable();
- 148 myDataTable.Columns.Add(new DataColumn("Last Name", typeof(String)));
- 149 myDataTable.Columns.Add(new DataColumn("First Name", typeof(String)));
- 150 myDataTable.Columns.Add(new DataColumn("Address", typeof(String)));
- 151 myDataTable.Columns.Add(new DataColumn("City", typeof(String)));
- 152 myDataTable.Columns.Add(new DataColumn("State", typeof(String)));
- 153
- 154 myActiveReport.DataSource = myDataTable;
- 155 myActiveReport.Run();
- 156 }
- 157
- 158 private void btnClose_Click(object sender, EventArgs e)
- 159 {
- 160 Close();
- 161 }
- 162 }
- 163 }
Ответить
|
Страница: 1 |
Поиск по форуму