翻譯|使用教程|編輯:王香|2018-08-16 09:34:06.000|閱讀 603 次
概述:本文詳細介紹了如何在TeeChart中多種形式打印圖表
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
【下載TeeChart.Net最新版本】
TeeChart Pro提供標準打印方法,可將“Onscreen Chart屏幕圖表”按原樣打印到打印機。
要打印圖表,請使用Print方法。這將打印出屏幕上顯示的圖表:
[C#.Net]
tChart1.Printer.Print();
[VB.Net]
TChart1.Printer.Print()
Print方法允許您使用布爾橫向參數打印橫向和縱向方向,即使它們未定義為默認方向。打印完成后,默認方向將再次生效。可以使用Landscape屬性更改默認方向(對于Landscape,設置為true,對于Portrait,設置為false):
[C#.Net]
tChart1.Printer.Landscape = true; tChart1.Printer.Print();
[VB.Net]
TChart1.Printer.Landscape = True TChart1.Printer.Print()
PrintPreview窗口將顯示打印時圖表的顯示方式,在“Print Preview window打印預覽”窗口中修改打印參數,要調用PrintPreview運行:
[C#.Net]
tChart1.Printer.Preview();
[VB.Net]
TChart1.Printer.Preview()
當打印到Greyscale打印機時,圖表的顏色在轉換為灰色陰影時很容易區分,為了提供幫助,可以在圖表系列中添加畫筆樣式,以便在打印時更輕松地區分系列,還可以使用灰度屬性將彩色圖表打印到彩色打印機:
[C#.Net]
tChart1.Printer.Grayscale = true; tChart1.Printer.Print(true);
[VB.Net]
TChart1.Printer.Grayscale = True TChart1.Printer.Print(True)
使用BeginPrint()和EndPrint()將圖表發送到打印機而不彈出頁面; BeginPrint()和EndPrint()開始和結束打印機作業。可以將多個圖表發送到同一頁面/打印機作業,也可以包含用戶自定義輸入,例:
[C#.Net]
private void button1_Click(object sender, System.EventArgs e) { tChart1.Printer.BeginPrint(); tChart1.Printer.Print(tChart2.Chart,new Rectangle(100,10,300,200)); tChart1.Printer.Print(new Rectangle(100,300,300,200)); tChart1.Printer.EndPrint(); }
[VB.Net]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TChart1.Printer.BeginPrint() TChart1.Printer.Print(TChart2.Chart, New Rectangle(100, 10, 300, 200)) TChart1.Printer.Print(New Rectangle(100, 300, 300, 200)) TChart1.Printer.EndPrint() End Sub
打印預覽器現在可以接受多個圖表,控制圖表位置設置Print方法的Rectangle,例:
[C#.Net]
private void button1_Click(object sender, System.EventArgs e) { tChart1.Printer.BeginPrint(); tChart1.Printer.Print(tChart2.Chart,new Rectangle(100,10,300,200)); tChart1.Printer.Print(new Rectangle(100,300,300,200)); tChart1.Printer.Preview(); }
[VB.Net]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TChart1.Printer.BeginPrint() TChart1.Printer.Print(TChart2.Chart, New Rectangle(100, 10, 300, 200)) TChart1.Printer.Print(New Rectangle(100, 300, 300, 200)) TChart1.Printer.Preview() End Sub
使用ChartPrint()事件將TeeChart打印輸出與非Chart打印機輸出混合,以下示例從TeeChart標題中獲取文本,并在具有兩個TChart對象的頁面上打印它們:
[C#.Net]
private void button1_Click(object sender, System.EventArgs e) { tChart1.Printer.BeginPrint(); tChart1.Printer.Print(tChart2.Chart,new Rectangle(100,10,300,200)); tChart1.Printer.Print(new Rectangle(100,300,300,200)); tChart1.Printer.EndPrint(); } private void tChart1_ChartPrint(object sender, System.Drawing.Printing.PrintPageEventArgs e) { e.Graphics.DrawString("Chart: "+((Steema.TeeChart.ChartPrintJob)sender).Chart.Header.Text, this.Font,new SolidBrush(Color.Black),100,((Steema.TeeChart.ChartPrintJob)sender).ChartRect.Bottom+10); }
[VB.Net]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TChart1.Printer.BeginPrint() TChart1.Printer.Print(TChart2.Chart, New Rectangle(100, 10, 300, 200)) TChart1.Printer.Print(New Rectangle(100, 300, 300, 200)) TChart1.Printer.EndPrint() End Sub Private Sub TChart1_ChartPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles TChart1.ChartPrint e.Graphics.DrawString("Chart: " & (CType(sender, Steema.TeeChart.ChartPrintJob)).Chart.Header.Text, _ Me.Font, New SolidBrush(Color.Black), 100, (CType(sender, Steema.TeeChart.ChartPrintJob)).ChartRect.Bottom + 10) End Sub
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn