打印来自db的账单记录的C#窗体我试过这个,但是,错误? [英] Print C# windows form for bill records from db I tried this but, error?

查看:66
本文介绍了打印来自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());

}

解决方案

从MSDN复制并粘贴时:如何:打印Windows窗体 [ ^ ]确保不要将_替换为。是个好主意。 ...



有更好的方法可以做到这一点:一种是直接打印表单 - 这实际上并不困难,Visual Basic中有一个类电源包为您完成: PrintForm Class (Microsoft.VisualBasic。 PowerPacks.Printing) [ ^ ]

但更好的方法是正确完成工作,并使用PrintDocument Class(System.Drawing.Printing) [ ^ ]这意味着用户只获取他的信息需要,而不是按钮等等 - 以及任何滚动页面信息也可以打印。该链接包含一个简单示例。


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

解决方案

When you copy and paste from MSDN: How to: Print a Windows Form[^] it's a good idea to make sure you don't replace "_" with "." ...

There are better ways to do this: one is to print the form directly - which isn't actually difficult, there is a class in the Visual Basic Power packs to do it for you: PrintForm Class (Microsoft.VisualBasic.PowerPacks.Printing)[^]
But a better way is to do the job properly, and use the PrintDocument Class (System.Drawing.Printing)[^] which means the user gets only the information he needs, and not the buttons and so forth as well - and any "scrolled off the page" information can be printed as well. The link includes a simple example.


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆