怎样将.dotnetcharting控件生成的图标打印
2010-04-01 15:25
435 查看
思想是将chart生成的报表转换成图片 ,然后打印。详细代码如下:
chart1.TempDirectory = "temp";
chart1.Debug = true;
chart1.Palette = new Color[] { Color.FromArgb(49, 255, 49), Color.FromArgb(255, 255, 0), Color.FromArgb(255, 99, 49), Color.FromArgb(0, 156, 255) };
chart1.Type = ChartType.Combo;
chart1.Width = 600;
chart1.Height = 350;
chart1.Title = ".netCHARTING Sample";
chart1.LegendBox.Visible = false;
chart1.DefaultSeries.Type = SeriesType.Line;
SeriesCollection mySC = getRandomData(); //数据集合
// Add the random data.
chart1.SeriesCollection.Add(mySC);
//chart1.
}
SeriesCollection getRandomData()
{
Random myR = new Random(1);
int startVal = 12000;
SeriesCollection SC = new SeriesCollection();
int a = 0;
int b = 0;
for (a = 1; a < 2; a++)
{
Series s = new Series("Series " + a.ToString());
for (b = 1; b < 10; b++)
{
Element e = new Element();
//e.XDateTime = DateTime.Now.AddDays(b);
e.XValue = b * 1;
e.YValue = startVal = startVal + (-7 + myR.Next(20));
s.Elements.Add(e);
}
SC.Add(s);
}
return SC;
}
private void button1_Click(object sender, EventArgs e)
{
//PrintDocument pd = new PrintDocument();
printDocument1.PrintPage += new PrintPageEventHandler
(this.PrintImageHandler);
this.printDialog1.AllowSomePages = true;
this.printDialog1.ShowHelp = true;
printDialog1.Document = printDocument1;
DialogResult Rest = printDialog1.ShowDialog();
if (Rest == DialogResult.OK)
{
printDocument1.Print();
}
}
private void PrintImageHandler(object sender,
PrintPageEventArgs ppeArgs)
{
Image curImage = chart1.GetChartBitmap();
Graphics g = ppeArgs.Graphics;
/*switch(this.s)
{
}*/
if (curImage != null)
{
// Draw Image using the DrawImage method
g.DrawImage(curImage, 100, 100,
curImage.Width, curImage.Height);
}
}
chart1.TempDirectory = "temp";
chart1.Debug = true;
chart1.Palette = new Color[] { Color.FromArgb(49, 255, 49), Color.FromArgb(255, 255, 0), Color.FromArgb(255, 99, 49), Color.FromArgb(0, 156, 255) };
chart1.Type = ChartType.Combo;
chart1.Width = 600;
chart1.Height = 350;
chart1.Title = ".netCHARTING Sample";
chart1.LegendBox.Visible = false;
chart1.DefaultSeries.Type = SeriesType.Line;
SeriesCollection mySC = getRandomData(); //数据集合
// Add the random data.
chart1.SeriesCollection.Add(mySC);
//chart1.
}
SeriesCollection getRandomData()
{
Random myR = new Random(1);
int startVal = 12000;
SeriesCollection SC = new SeriesCollection();
int a = 0;
int b = 0;
for (a = 1; a < 2; a++)
{
Series s = new Series("Series " + a.ToString());
for (b = 1; b < 10; b++)
{
Element e = new Element();
//e.XDateTime = DateTime.Now.AddDays(b);
e.XValue = b * 1;
e.YValue = startVal = startVal + (-7 + myR.Next(20));
s.Elements.Add(e);
}
SC.Add(s);
}
return SC;
}
private void button1_Click(object sender, EventArgs e)
{
//PrintDocument pd = new PrintDocument();
printDocument1.PrintPage += new PrintPageEventHandler
(this.PrintImageHandler);
this.printDialog1.AllowSomePages = true;
this.printDialog1.ShowHelp = true;
printDialog1.Document = printDocument1;
DialogResult Rest = printDialog1.ShowDialog();
if (Rest == DialogResult.OK)
{
printDocument1.Print();
}
}
private void PrintImageHandler(object sender,
PrintPageEventArgs ppeArgs)
{
Image curImage = chart1.GetChartBitmap();
Graphics g = ppeArgs.Graphics;
/*switch(this.s)
{
}*/
if (curImage != null)
{
// Draw Image using the DrawImage method
g.DrawImage(curImage, 100, 100,
curImage.Width, curImage.Height);
}
}
相关文章推荐
- .net使用DotNetCharting控件生成报表统计图总结
- C#.net使用DotNetCharting控件生成报表统计图--A
- 转载--.net使用DotNetCharting控件生成报表统计图总结
- .net使用DotNetCharting控件生成报表统计图总结 (http://www.cnblogs.com/dreamof/archive/2008/07/18/1245887.html)
- .net使用DotNetCharting控件生成报表统计图总结
- .net使用DotNetCharting控件生成报表统计图总结
- 保存dotNetCharting for WinForm 控件的生成的图表
- asp.net使用DotNetCharting控件生成报表统计图
- .net使用DotNetCharting控件生成报表统计图总结[转自—飛雪飄寒]
- net使用DotNetCharting控件生成报表统计图总结
- net使用DotNetCharting控件生成报表统计图
- .net使用DotNetCharting控件生成报表统计图总结 (转地址)
- asp.net使用DotNetCharting控件生成报表统计图总结
- C#.net使用DotNetCharting控件生成报表统计图
- .NET使用DotNetCharting控件生成报表统计图总结
- 使用DotNetCharting控件生成报表统计图
- 统计图控件dotnetCharting和ZedGraph比较
- 添加条码生成和打印功能到您的ASP.NET Web的条码控件Barcode Professional for ASP.NET
- dotnetCHARTING.dll 图表控件的使用