Visual Basic, .NET, ASP, VBScript
 

   
   
     

Форум - Общий форум

Страница: 1 |

 

  Вопрос: reportviewer Добавлено: 13.02.12 16:39  

Автор вопроса:  Nikos
c# как программно изменить значение textbox в reportviewer, а точнее в report.rdlc, чтоб можно было по нажатию кнопки менять этот textbox

Ответить

  Ответы Всего ответов: 1  

Номер ответа: 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

или с одного блога(сам прмер привести не погу, примерно помню как делал, сейчас глючит студия - не могу репорт создать):
  1.  
  2. using System;
  3. 002 using System.Collections.Generic;
  4. 003 using System.ComponentModel;
  5. 004 using System.Data;
  6. 005 using System.Data.Common;
  7. 006 using System.Data.SqlClient;
  8. 007 using System.Drawing;
  9. 008 using System.Linq;
  10. 009 using System.Text;
  11. 010 using System.Windows.Forms;
  12. 011 using DataDynamics.ActiveReports;
  13. 012 using DataDynamics.ActiveReports.DataSources;
  14. 013 using DataDynamics.ActiveReports.Design;
  15. 014 using DataDynamics.ActiveReports.Document;
  16. 015 using DataDynamics.ActiveReports.Viewer;
  17. 016 using Microsoft.Reporting.WinForms;
  18. 017 using Microsoft.ReportingServices.ReportRendering;
  19. 018
  20. 019 namespace CustomerInfoReport
  21. 020 {
  22. 021     public partial class Form1 : Form
  23. 022     {
  24. 023         // declare variables
  25. 024         SqlDBDataSource myDataSource = new SqlDBDataSource();
  26. 025         
  27. 026         public Form1()
  28. 027         {
  29. 028             InitializeComponent();
  30. 029
  31. 030             // create connection
  32. 031             myDataSource.ConnectionString = @"Data Source=NED-CREATIVE;initial catalog=C:\\SQL SERVER 2000 SAMPLE DATABASES\\NORTHWND.MDF;integrated security=SSPI;persist security info=False";
  33. 032         }
  34. 033     
  35. 034         private void btnReport_Click(object sender, EventArgs e)
  36. 035         {
  37. 036             myDataSource.SQL = @"Select * from Employees";
  38. 037
  39. 038             ActiveReport3 myActiveReport = new ActiveReport3();
  40. 039
  41. 040             // header section
  42. 041             ReportHeader rHeader = new ReportHeader();
  43. 042             rHeader.Name = "pageHeader";
  44. 043             rHeader.BackColor = Color.Transparent;
  45. 044
  46. 045             myActiveReport.Sections.Add(rHeader);
  47. 046
  48. 047             // add controls to header section
  49. 048             
  50. 049             // Title
  51. 050             DataDynamics.ActiveReports.Label label1 = new DataDynamics.ActiveReports.Label();
  52. 051             label1.Text = "Employees Address Report";
  53. 052             label1.Style = "font-weight: bold; font-size: 15.75pt;";
  54. 053             label1.Location = new PointF(2.31f, 0.13f);
  55. 054             rHeader.Controls.Add(label1);
  56. 055             
  57. 056             // Date/Time
  58. 057             DataDynamics.ActiveReports.ReportInfo reportInfo1 = new DataDynamics.ActiveReports.ReportInfo();
  59. 058             reportInfo1.FormatString = "{RunDateTime:M/d/yyy}";
  60. 059             reportInfo1.Location = new PointF(0.06f, 0.19f);
  61. 060             rHeader.Controls.Add(reportInfo1);
  62. 061
  63. 062             // Page Number
  64. 063             DataDynamics.ActiveReports.ReportInfo reportInfo2 = new DataDynamics.ActiveReports.ReportInfo();
  65. 064             reportInfo2.FormatString = "Page {PageNumber} of {PageCount}";
  66. 065             reportInfo2.Location = new PointF(6.38f, 0.19f);
  67. 066             rHeader.Controls.Add(reportInfo2);
  68. 067
  69. 068             // Detail section
  70. 069             Detail myDetails = new Detail();
  71. 070             myDetails.Name = "pageDetail";
  72. 071             myActiveReport.Sections.Add(myDetails);
  73. 072
  74. 073             // add controls to detail section
  75. 074             
  76. 075             // Last Name label
  77. 076             DataDynamics.ActiveReports.Label label2 = new DataDynamics.ActiveReports.Label();
  78. 077             label2.Text = "Last Name";
  79. 078             label2.Location = new PointF(0.06f, 0.06f);
  80. 079             myDetails.Controls.Add(label2);
  81. 080             
  82. 081             // First Name label
  83. 082             DataDynamics.ActiveReports.Label label3 = new DataDynamics.ActiveReports.Label();
  84. 083             label3.Text = "First Name";
  85. 084             label3.Location = new PointF(1.13f, 0.06f);
  86. 085             myDetails.Controls.Add(label3);
  87. 086
  88. 087             // Address label
  89. 088             DataDynamics.ActiveReports.Label label4 = new DataDynamics.ActiveReports.Label();
  90. 089             label4.Text = "Address";
  91. 090             label4.Location = new PointF(2.44f, 0.06f);
  92. 091             myDetails.Controls.Add(label4);
  93. 092
  94. 093             // City label
  95. 094             DataDynamics.ActiveReports.Label label5 = new DataDynamics.ActiveReports.Label();
  96. 095             label5.Text = "City";
  97. 096             label5.Location = new PointF(4.56f, 0.06f);
  98. 097             myDetails.Controls.Add(label5);
  99. 098
  100. 099             // State label
  101. 100             DataDynamics.ActiveReports.Label label6 = new DataDynamics.ActiveReports.Label();
  102. 101             label6.Text = "State";
  103. 102             label6.Location = new PointF(5.69f, 0.06f);
  104. 103             myDetails.Controls.Add(label6);
  105. 104             
  106. 105             //Last Name textbox
  107. 106             DataDynamics.ActiveReports.TextBox txtLastName1 = new DataDynamics.ActiveReports.TextBox();
  108. 107             txtLastName1.DataField = "LastName";
  109. 108             txtLastName1.Text = "txtLastName1";
  110. 109             txtLastName1.Location = new PointF(0.06f, 0.31f);
  111. 110             txtLastName1.Name = "txtLastName1";
  112. 111             myDetails.Controls.Add(txtLastName1);
  113. 112
  114. 113             DataDynamics.ActiveReports.TextBox txtFirstName1 = new DataDynamics.ActiveReports.TextBox();
  115. 114             txtFirstName1.DataField = "FirstName";
  116. 115             txtFirstName1.Text = "txtFirstName1";
  117. 116             txtFirstName1.Location = new PointF(1.13f, 0.31f);
  118. 117             txtFirstName1.Name = "txtFirstName1";
  119. 118             myDetails.Controls.Add(txtFirstName1);
  120. 119
  121. 120             DataDynamics.ActiveReports.TextBox txtAddress1 = new DataDynamics.ActiveReports.TextBox();
  122. 121             txtAddress1.DataField = "Address";
  123. 122             txtAddress1.Text = "txtAddress1";
  124. 123             txtAddress1.Location = new PointF(2.44f, 0.31f);
  125. 124             txtAddress1.Name = "txtAddress1";
  126. 125             myDetails.Controls.Add(txtAddress1);
  127. 126
  128. 127             DataDynamics.ActiveReports.TextBox txtCity1 = new DataDynamics.ActiveReports.TextBox();
  129. 128             txtCity1.DataField = "City";
  130. 129             txtCity1.Text = "txtCity1";
  131. 130             txtCity1.Location = new PointF(4.56f, 0.31f);
  132. 131             txtCity1.Name = "txtCity1";
  133. 132             myDetails.Controls.Add(txtCity1);
  134. 133
  135. 134             DataDynamics.ActiveReports.TextBox txtRegion1 = new DataDynamics.ActiveReports.TextBox();
  136. 135             txtRegion1.DataField = "Region";
  137. 136             txtRegion1.Text = "txtRegion1";
  138. 137             txtRegion1.Location = new PointF(5.69f, 0.31f);
  139. 138             txtRegion1.Name = "txtRegion1";
  140. 139             myDetails.Controls.Add(txtRegion1);
  141. 140
  142. 141             // corresponding footers.
  143. 142             ReportFooter myFooter = new ReportFooter();
  144. 143             myFooter.Name = "pageFooter";
  145. 144             myActiveReport.Sections.Add(myFooter);
  146. 145             
  147. 146             // create DataTable with columns
  148. 147             DataTable myDataTable = new DataTable();
  149. 148             myDataTable.Columns.Add(new DataColumn("Last Name", typeof(String)));
  150. 149             myDataTable.Columns.Add(new DataColumn("First Name", typeof(String)));
  151. 150             myDataTable.Columns.Add(new DataColumn("Address", typeof(String)));
  152. 151             myDataTable.Columns.Add(new DataColumn("City", typeof(String)));
  153. 152             myDataTable.Columns.Add(new DataColumn("State", typeof(String)));
  154. 153
  155. 154             myActiveReport.DataSource = myDataTable;
  156. 155             myActiveReport.Run();
  157. 156         }
  158. 157         
  159. 158         private void btnClose_Click(object sender, EventArgs e)
  160. 159         {
  161. 160             Close();
  162. 161         }
  163. 162     }
  164. 163 }

Ответить

Страница: 1 |

Поиск по форуму



© Copyright 2002-2011 VBNet.RU | Пишите нам