Hi Friend,
I create customer application Project in window application.
In that project i create one form as customer details.
After enter customer details i want to print that details using print dialog controls.
I got all details to print in fixed position on my form,expect customer photo.
How i can print customer photo in my fixed position on form.
Please any one give the Immediately solution.
This is my coding.
-------------------------------
float ScreenResolution = 96.0f;
private void Form1_Paint(object sender, PaintEventArgs e)
{
ScreenResolution = e.Graphics.DpiX;
}
void DrawForm(Graphics g, int resX, int resY)
{
g.FillRectangle(new SolidBrush(this.BackColor), 0, 0, this.Width, this.Height);
float scale = resX / ScreenResolution;
foreach (Control c in Controls)
{
string strType = c.GetType().ToString().Substring(c.GetType().ToString().LastIndexOf(".") + 1);
switch (strType)
{
case "Label":
// ControlPaint.FillReversibleRectangle( ((TextBox)c).Bounds, c.BackColor);
Label l = (Label)c;
ControlPaint.DrawButton(g, l.Left, l.Top, l.Width, l.Height, ButtonState.Pushed);
g.FillRectangle(new SolidBrush(l.BackColor), l.Left + 1, l.Top + 1, l.Width + 2, l.Height - 2);
g.DrawString(l.Text, l.Font, new SolidBrush(l.ForeColor), l.Left + 2, l.Top + l.Height / 2 - g.MeasureString("a", l.Font).Height / 2, new StringFormat());
break;
case "TextBox":
TextBox t = (TextBox)c;
ControlPaint.DrawButton(g, t.Left, t.Top, t.Width, t.Height, ButtonState.Pushed);
g.FillRectangle(new SolidBrush(t.BackColor), t.Left + 1, t.Top + 1, t.Width + 2, t.Height - 2);
g.DrawString(t.Text, t.Font, new SolidBrush(t.ForeColor), t.Left + 2, t.Top + t.Height / 2 - g.MeasureString("a", t.Font).Height / 2, new StringFormat());
break;
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
PrinterResolution pr = e.PageSettings.PrinterResolution;
DrawForm(e.Graphics, pr.X, pr.Y);
}
Loading
sharmila kPosted Aug 24, 2012, 4:05 AM
Thank You For your reply.
But i got all controls details like(label,textbox) content expect photo(picture).
I put some code i got image also but i want to display that image in fixed position on my form.
It will be display top of the corner in my form.
Please any one give Immediately solution.
This is my coding
----------------------------
case "PictureBox":
PictureBox p = (PictureBox)c;
Bitmap myBitmap1 = new Bitmap(p.Width, p.Height);
p.DrawToBitmap(myBitmap1, new Rectangle(0, 0, p.Width, p.Height));
g.DrawImage(myBitmap1, 0, 0);
myBitmap1.Dispose();
break;
rahul jaiswalPosted Aug 24, 2012, 3:54 AM