彩票走势图

logo 【TeeChart Pro ActiveX教程】2018
文档彩票走势图>>【TeeChart Pro ActiveX教程】2018>>【TeeChart Pro ActiveX教程】(十四):打印图表

【TeeChart Pro ActiveX教程】(十四):打印图表


下载TeeChart Pro ActiveX最新版本

标准打印

TeeChart Pro提供标准打印方法,可将“屏幕图表”按原样打印到打印机。

简单打印命令

要打印图表,请使用Print方法。这将打印出屏幕上显示的图表:

[C#]

tChart1.Printer.Print(); 

[VB.Net]

TChart1.Printer.Print()

打印方向

Print方法允许您通过使用布尔横向参数来打印横向和纵向方向,即使它们未被定义为默认方向。打印完成后,默认方向将再次生效。可以使用Landscape属性更改默认方向(对于Landscape,设置为true,对于Portrait,设置为false):

[C#]

tChart1.Printer.Landscape = true; 
tChart1.Printer.Print();

[VB.Net]

TChart1.Printer.Landscape = True 
TChart1.Printer.Print()

打印预览

PrintPreview窗口将显示打印时图表的显示方式。您可以在“打印预览”窗口中修改打印参数。要调用PrintPreview运行:

[C#]

tChart1.Printer.Preview(); 

[VB.Net]

TChart1.Printer.Preview()

灰度打印

当打印到Greyscale打印机时,您应该注意图表的颜色在转换为灰色阴影时很容易区分。为了提供帮助,您可以在图表系列中添加画笔样式,以便在打印时更轻松地区分系列。

您还可以使用灰度属性将彩色图表打印到彩色打印机:

[C#]

tChart1.Printer.Grayscale = true; 
tChart1.Printer.Print(true); 

[VB.Net]

TChart1.Printer.Grayscale = True 
TChart1.Printer.Print(True) 

扩展打印方法

打印多个图表

使用BeginPrint()和EndPrint()将图表发送到打印机而不弹出页面; BeginPrint()和EndPrint()开始和结束打印机作业。可以将多个图表发送到同一页面/打印机作业,也可以包含用户自定义输入。

(将2个图表打印到页面)

[C#]

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。

(在打印预览器中显示2个图表)

[C#]

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#]

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 

购买TeeChart Pro AciveX正版授权,请点击“”哟!

扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP