어떻게 C 날카로운 코드프로그래밍
Q
프로그래밍
3
A
답변
4
하지 마십시오을 사용하여 보고서 뷰어의 인쇄 버튼을 호출 할 수 있습니다.
먼저 사용자에게 미리보기를 표시하지 않고 프로그래밍 방식으로 보고서를 인쇄하십시오. 인쇄 장치의 이름을 지정하기 만하면 사용자 개입없이 보고서가 자동으로 인쇄됩니다. 샘플 코드는 Walkthrough: Printing a Local Report without Preview입니다.
0
은 내가 성공적으로 사용했다 : 인쇄 대화 상자를 보여줍니다
this.reportviewer1.PrintDialog();
을하여 인쇄를 제어하는 사용자를 허용한다. 희망이 도움이 될까요?
+0
ReportViewer1 – monstro
+0
에 속하는 PrintDialog()라는 메서드가 작동하지 않습니다. –
0
directly copy this code in a class called "Printing" and Call the "Run" method with your reportviewer name as parameter. Example obj.Run(reportviewer1);
////////////////////////////////////////////////////////////////////////////////////
using System;
using System.IO;
using System.Data;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Printing;
using System.Collections.Generic;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;
class Printing
{
private int m_currentPageIndex;
private IList m_streams;
private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek)
{
Stream stream = new MemoryStream();
m_streams.Add(stream);
return stream;
}
private void Export(LocalReport report)
{
string deviceInfo =
@"
EMF
8.5in
11in
0.25in
0.25in
0.25in
0.25in
";
Warning[] warnings;
m_streams = new List();
report.Render("Image", deviceInfo, CreateStream,
out warnings);
foreach (Stream stream in m_streams)
stream.Position = 0;
}
private void PrintPage(object sender, PrintPageEventArgs ev)
{
Metafile pageImage = new
Metafile(m_streams[m_currentPageIndex]);
// Adjust rectangular area with printer margins.
Rectangle adjustedRect = new Rectangle(
ev.PageBounds.Left - (int)ev.PageSettings.HardMarginX,
ev.PageBounds.Top - (int)ev.PageSettings.HardMarginY,
ev.PageBounds.Width,
ev.PageBounds.Height);
// Draw a white background for the report
ev.Graphics.FillRectangle(Brushes.White, adjustedRect);
// Draw the report content
ev.Graphics.DrawImage(pageImage, adjustedRect);
// Prepare for the next page. Make sure we haven't hit the end.
m_currentPageIndex++;
ev.HasMorePages = (m_currentPageIndex < m_streams.Count);
}
private void Print()
{
if (m_streams == null || m_streams.Count == 0)
throw new Exception("Error: no stream to print.");
PrintDocument printDoc = new PrintDocument();
if (!printDoc.PrinterSettings.IsValid)
{
throw new Exception("Error: cannot find the default printer.");
}
else
{
printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
m_currentPageIndex = 0;
printDoc.Print();
}
}
public void Run(ReportViewer rpt)
{
Export(rpt.LocalReport);
Print();
}
public void Dispose()
{
if (m_streams != null)
{
foreach (Stream stream in m_streams)
stream.Close();
m_streams = null;
}
}
}
관련 문제
- 1. Mac 프로그래밍 Android 프로그래밍 프로그래밍
- 2. 프로그래밍
- 3. 프로그래밍
- 4. 프로그래밍
- 5. 프로그래밍
- 6. 프로그래밍
- 7. 프로그래밍
- 8. 프로그래밍
- 9. 프로그래밍
- 10. 프로그래밍
- 11. 프로그래밍
- 12. 프로그래밍
- 13. 프로그래밍
- 14. 프로그래밍
- 15. 프로그래밍
- 16. 프로그래밍
- 17. UIView 지역화 프로그래밍 방식으로 프로그래밍
- 18. 웹 프로그래밍 대 소프트웨어 프로그래밍
- 19. 선언적 프로그래밍 및 명령형 프로그래밍
- 20. D 프로그래밍 Fedora 16에서 프로그래밍
- 21. "프로그래밍 인터페이스"및 "프로그래밍 프로그래밍"이란 무엇을 의미합니까?
- 22. Open DateTimePicker C# 프로그래밍 방식으로 프로그래밍
- 23. 스토리 보드로 프로그래밍 언어를 프로그래밍 방식으로 변경
- 24. 모듈 식 프로그래밍 및 구조화 프로그래밍
- 25. drupal에서 프로그래밍 방식으로 프로그래밍 테마 변경
- 26. Android 계층 프로그래밍 뷰어 프로그래밍 인터페이스
- 27. 비 프로그래밍 적분의 경우 동적 프로그래밍
- 28. 시스템 프로그래밍 언어와 응용 프로그래밍 언어의 차이점
- 29. MOTION_EVENT 프로그래밍 방식으로 프로그래밍 할 수 있습니까?
- 30. 처음 C 프로그래밍 방법을 사용하여 프로그래밍
그러나 보고서 뷰어 컨트롤에 .rdlc 파일을 표시하고 사용자 지정 단추를 사용하여 해당 보고서 파일을 인쇄해야합니다.이 문제를 해결하려면 어떻게해야합니까? – user1146956
@ user1146956 : 버튼이나 뷰어 컨트롤을 제거 할 필요가 없습니다. 그러나 사용자 개입없이 * 보고서 *를 인쇄하려면 * 위 링크에서 제안한대로해야합니다. 코드를 사용하여 버튼을 클릭하지 마십시오. 그게 잘 풀리지 않을거야. –