翻譯|使用教程|編輯:王香|2018-08-16 09:34:06.000|閱讀 603 次
概述:本文詳細(xì)介紹了如何在TeeChart中多種形式打印圖表
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷(xiāo)售中 >>
相關(guān)鏈接:
【下載TeeChart.Net最新版本】
TeeChart Pro提供標(biāo)準(zhǔn)打印方法,可將“Onscreen Chart屏幕圖表”按原樣打印到打印機(jī)。
要打印圖表,請(qǐng)使用Print方法。這將打印出屏幕上顯示的圖表:
[C#.Net]
tChart1.Printer.Print();
[VB.Net]
TChart1.Printer.Print()
Print方法允許您使用布爾橫向參數(shù)打印橫向和縱向方向,即使它們未定義為默認(rèn)方向。打印完成后,默認(rèn)方向?qū)⒃俅紊А?可以使用Landscape屬性更改默認(rèn)方向(對(duì)于Landscape,設(shè)置為true,對(duì)于Portrait,設(shè)置為false):
[C#.Net]
tChart1.Printer.Landscape = true; tChart1.Printer.Print();
[VB.Net]
TChart1.Printer.Landscape = True TChart1.Printer.Print()
PrintPreview窗口將顯示打印時(shí)圖表的顯示方式,在“Print Preview window打印預(yù)覽”窗口中修改打印參數(shù),要調(diào)用PrintPreview運(yùn)行:
[C#.Net]
tChart1.Printer.Preview();
[VB.Net]
TChart1.Printer.Preview()
當(dāng)打印到Greyscale打印機(jī)時(shí),圖表的顏色在轉(zhuǎn)換為灰色陰影時(shí)很容易區(qū)分,為了提供幫助,可以在圖表系列中添加畫(huà)筆樣式,以便在打印時(shí)更輕松地區(qū)分系列,還可以使用灰度屬性將彩色圖表打印到彩色打印機(jī):
[C#.Net]
tChart1.Printer.Grayscale = true; tChart1.Printer.Print(true);
[VB.Net]
TChart1.Printer.Grayscale = True TChart1.Printer.Print(True)
使用BeginPrint()和EndPrint()將圖表發(fā)送到打印機(jī)而不彈出頁(yè)面; BeginPrint()和EndPrint()開(kāi)始和結(jié)束打印機(jī)作業(yè)。可以將多個(gè)圖表發(fā)送到同一頁(yè)面/打印機(jī)作業(yè),也可以包含用戶自定義輸入,例:
[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
打印預(yù)覽器現(xiàn)在可以接受多個(gè)圖表,控制圖表位置設(shè)置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打印機(jī)輸出混合,以下示例從TeeChart標(biāo)題中獲取文本,并在具有兩個(gè)TChart對(duì)象的頁(yè)面上打印它們:
[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
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn