[RESOLVED] Add graph to form
I have created a line graph in C# but it doesnt appear. Ideally I would like it to displayed on a new Windows Form or in IE. This is the code I used to plot it on stage:
Code:
protected void PlotGraph()
{
// Plot the whole graph in form at coordinates (0,0)
Form statsForm = new Form();
objGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
statsForm.Controls.Add(objGraphics.DrawImageUnscaled(objBitmap, new Point(0,0))); // Doesnt work!
// ALSO TRIED:
// objGraphics.DrawImageUnscaled(objBitmap, new Point(0, 0)); // DOESNT APPEAR
// AND:
//objBitmap.Save(Response.OutputStream, ImageFormat.Png); // DOESNT APPEAR
// AND:
// Render BitMap Stream Back To Client
//Bitmap StockBitMap;
//Response.ContentType = "image/png";
//MemoryStream memStream = new MemoryStream();
//StockBitMap.Save(memStream, ImageFormat.Png);
//memStream.WriteTo(Response.OutputStream);
}
Re: [RESOLVED] Add graph to form
Checkout e.Graphics, where 'e' is passed into the OnPaint handler.
Code:
Graphics g = e.Graphics;
This is what is generally the first line of a User written OnPaint override.
If you call the Invalidate() method on a control, it will cause that control's OnPaint handler to be called. That's how you call OnPaint, not directly.
Re: [RESOLVED] Add graph to form
Thanks, ill keep that in mind!