Re: Printing custom control
What do you mean by print? Do you mean you only want to draw specific element of the control? If so, show the OnPaint code.
Re: Printing custom control
One down and dirty way is to get the image of the control into a bitmap the you can manipulate the image however you want, including drawing over regions that you dont want.
Re: Printing custom control
@Pickels
You are right. Thats is what I am trying to do.
Here is my code (psudo code)
In My chartUserControl
public Graphics graphicWithoutData;
private void drawingPanel_Paint_1(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics
DrawGrid(g);
DrawShape(g);
graphicWithoutData = g;
//I even tried with bitmap
Size s = this.Size;
BitmapWithoutDistData = new Bitmap(s.Width, s.Height, g);
DrawData(g);
}
when i try to access graphicWithoutData (public member) in my main form, it gave me an exception : Invalid parameter.
When I try to print BitmapWithoutDistData (public member) in my main form, it was blank
Is there any wrong in my way of approach to this problem.
If you know any other way let me know.
@[email protected]
Above is my code. But even that bitmap (BitmapWithoutDistData) is blank. i.e when I print it on doc it was blank
Re: Printing custom control
try doing it this way
Code:
private void drawingPanel_Paint_1(object sender, PaintEventArgs e)
{
using (Bitmap bmp = new Bitmap(s.Width, s.Height))
{
using (Graphics g = Graphics.FromImage(bmp))
{
DrawGrid(g);
DrawShape(g);
}
//At this point bmp should be the image I think you are looking for
e.Graphics.DrawImage(bmp) ;
DrawData(e.Graphics);
}
}
Re: Printing custom control