Print components
Hej eksperter. Jeg er kommet lidt i vildrede. Jeg har en . NET component, VareLinjeControl. Denne består KUN af textboxe. Mit problem er så at jeg ikke kan skrive denne ud. Og håber på i kan give mig et svar på hvorfor denne ikke vil udskrives. :)Min kode er som følger:
private void TegnAlt(Graphics g)
{
RectangleF srcRect = new Rectangle(0, 0, this.BackgroundImage.Width,
BackgroundImage.Height);
int nWidth = printDocument1.PrinterSettings.DefaultPageSettings.PaperSize.Width;
int nHeight = printDocument1.PrinterSettings.DefaultPageSettings.PaperSize.Height;
RectangleF destRect = new Rectangle(0, 0, nWidth, nHeight / 2);
g.DrawImage(this.BackgroundImage, destRect, srcRect, GraphicsUnit.Pixel);
float scalex = destRect.Width / srcRect.Width;
float scaley = destRect.Height / srcRect.Height;
Pen aPen = new Pen(Brushes.Black, 1);
for (int i = 0; i < this.Controls.Count; i++)
{
if (Controls[i].GetType() == this.tbKunde.GetType())
{
TextBox theText = (TextBox)Controls[i];
g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left * scalex, theText.Bounds.Top * scaley, new StringFormat());
}
if (Controls[i].GetType() == this.vareLinjeControl21.GetType())
{
WindowsApplication1.VareLinjeControl winVareLin = (WindowsApplication1.VareLinjeControl)Controls[i];
g.DrawString(winVareLin.Text, winVareLin.Font, Brushes.Black, winVareLin.Bounds.Left * scalex, winVareLin.Bounds.Top * scaley, new StringFormat());
}
if (Controls[i].GetType() == this.checkBox1.GetType())
{
CheckBox theCheck = (CheckBox)Controls[i];
Rectangle aRect = theCheck.Bounds;
g.DrawRectangle(aPen, aRect.Left * scalex, aRect.Top * scaley, aRect.Width * scalex, aRect.Height * scaley);
if (theCheck.Checked)
{
g.DrawString("x", theCheck.Font, Brushes.Black,
theCheck.Left * scalex + 1, theCheck.Top * scaley + 1, new StringFormat());
}
}
}
}
Det er i linjerne med:
if (Controls[i].GetType() == this.vareLinjeControl21.GetType())
{
WindowsApplication1.VareLinjeControl winVareLin = (WindowsApplication1.VareLinjeControl)Controls[i];
g.DrawString(winVareLin.Text, winVareLin.Font, Brushes.Black, winVareLin.Bounds.Left * scalex, winVareLin.Bounds.Top * scaley, new StringFormat());
}
At problemet er. Den compailer men vil ikke udskrive selve componentet og dets indhold. Er dette overhovedet muligt?
Mvh
Martin Sørensen
