1
我在贏取窗體中使用圖表,嘗試在按鈕的單擊事件中查看打印預覽。嘗試this.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();
}
運作,但需要一點點修正:ppd.Document = this.chart1.Printing.PrintDocument; – Jhollman 2017-04-01 14:07:05