this is c# windows application about physiotherapy mgt system , i want to print bill about patient P_name,pain,no.of visit,total_charge and total_paid by particular contact no. because it's unique so, i print windows form. i did as following but, there is error in click event.
printButton.Click += new EventHandler(printButton.Click);
Error: "System.Windows.Form.Control.Click" can only appear on left hand side of += or -=
the code as follow.
crt_usr is form when i developed code.
there is some mistake and error please guide, sir, if i wrong tell me right way for print bill about define above. thank you in advance
What I have tried:
public void crt_user()
{
printButton.Text = "Print";
printButton.Click += new EventHandler(printButton.Click);
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
this.Controls.Add(printButton);
}
public void printButton_Click(object sender, EventArgs e)
{
Capturescreen();
pd.Print();
}
Bitmap memoryimage;
private void Capturescreen()
{
Graphics myGraphics = this.CreateGraphics();
Size s = this.Size;
memoryimage = new Bitmap(s.Width, s.Height, myGraphics);
Graphics memoryGraphics = Graphics.FromImage(memoryimage);
memoryGraphics.CopyFromScreen(this.Location.X, this.Location.Y, 0, 0, s);
}
private void pd_PrintPage(System.Object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(memoryimage, 0, 0);
}
public static void Main()
{
Application.Run(new crt_usr());
}