本文介绍了打印来自db的账单记录的C#窗体我试过这个,但是,错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是关于理疗mgt系统的c#windows应用程序,我想通过特定联系号打印关于患者P_name,疼痛,访问次数,总次数和total_paid的帐单。因为它是独一无二的,所以我打印窗体。我做了如下但是,点击事件有错误。



 printButton.Click + = new EventHandler(printButton.Click) ; 







错误:System.Windows.Form.Control.Click可以只出现在+ =或 - =



左侧的代码如下。





crt_usr是我开发代码的形式。



有一些错误和错误请指导,先生,如果我错了告诉我正确的方法关于上面定义的打印账单。提前谢谢



我的尝试:



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();

}

位图memoryimage;

private void Capturescreen()

{

Graphics myGraphics = this.CreateGraphics();

Size s = this.Size;

memoryimage = new Bitmap(s.Width,s.Height,myGraphics);

图形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());

}

解决方案


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());
}

解决方案


这篇关于打印来自db的账单记录的C#窗体我试过这个,但是,错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 09:17