2014-09-24 2 views
1

단추의 클릭 이벤트에서 인쇄 미리보기를 보려고하는 win-forms 차트를 사용하고 있습니다. 이 시도했다. chart1.Printing.PrintPreview()하지만 빈 페이지를 보여줍니다. 여기 차트의 인쇄 미리보기 C#

내 코드

//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(); 
} 

답변

2

이 시도

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

작품이지만, 약간의 수정이 필요 : ppd.Document = this.chart1.Printing.PrintDocument을; – Jhollman