图表的打印预览c#

贾根

我在win-forms中使用图表,试图查看按钮的click事件上的打印预览。尝试了this.chart1.Printing.PrintPreview(),但它显示了一个空白页面。

这是我的代码

//at form load
{
    if (objMaster == null) objMaster = new MasterEstimateSales();
    dt = new DataTable();
    dt = objMaster.ESChart(); 
    chart1.DataSource = dt;
    var series = new Series();
    series.Name = "Sale";
    series.ChartType = SeriesChartType.Bar;
    chart1.Series.Add(series);
    chart1.Series["Sale"].XValueMember = "Variety";
    chart1.Series["Sale"].YValueMembers = "Quantity";
    chart1.ChartAreas[0].AxisY.ScaleBreakStyle.Enabled = true;
    series.IsValueShownAsLabel = true;
    chart1.ChartAreas[0].AxisX.MajorGrid.LineWidth = 0;
    chart1.ChartAreas[0].AxisY.MajorGrid.LineWidth = 0;
    chart1.ChartAreas[0].AxisX.Interval = 1;
    chart1.ChartAreas[0].AxisX.LabelStyle.Font= new System.Drawing.Font("AParanarTSC", 9F, System.Drawing.FontStyle.Regular);

}
// Button Event
private void button1_Click(object sender, EventArgs e)
{
    this.chart1.Printing.PrintPreview();
}
学习者

试试这个,

PrintPreviewDialog ppd = new PrintPreviewDialog();
ppd.Document = this.chart1.PrintDocument;
ppd.ShowDialog();

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章