[高难度问题!]请问怎么用c#制作工资条的打印?[急!!急!!!急!!!]
请讲的细致点,我知道这是个很累人的事,但是真的很急啊~求高手帮忙!! --------------------编程问答-------------------- 1:可以使用报表设置器2:可以使用内置的PrintDocument来自定义绘制.
通常可以创建 PrintDocument 类的实例,设置描述打印方式的属性,然后调用 Print 方法开始打印进程。通过使用 PrintPageEventArgs 中包含的 Graphics 来处理用于指定打印输出的 PrintPage 事件。 --------------------编程问答-------------------- 下面的例子是一个打印文件的,可以做为自定义打印的一个参考:
public class PrintingExample : System.Windows.Forms.Form
{
private System.ComponentModel.Container components;
private System.Windows.Forms.Button printButton;
private Font printFont;
private StreamReader streamToPrint;
public PrintingExample() : base()
{
// The Windows Forms Designer requires the following call.
InitializeComponent();
}
// The Click event is raised when the user clicks the Print button.
private void printButton_Click(object sender, EventArgs e)
{
try
{
streamToPrint = new StreamReader
("C:\\My Documents\\MyFile.txt");
try
{
printFont = new Font("Arial", 10);
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler
(this.pd_PrintPage);
pd.Print();
}
finally
{
streamToPrint.Close();
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
// The PrintPage event is raised for each page to be printed.
private void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
float linesPerPage = 0;
float yPos = 0;
int count = 0;
float leftMargin = ev.MarginBounds.Left;
float topMargin = ev.MarginBounds.Top;
string line = null;
// Calculate the number of lines per page.
linesPerPage = ev.MarginBounds.Height /
printFont.GetHeight(ev.Graphics);
// Print each line of the file.
while(count < linesPerPage &&
((line=streamToPrint.ReadLine()) != null))
{
yPos = topMargin + (count *
printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString(line, printFont, Brushes.Black,
leftMargin, yPos, new StringFormat());
count++;
}
// If more lines exist, print another page.
if(line != null)
ev.HasMorePages = true;
else
ev.HasMorePages = false;
}
// The Windows Forms Designer requires the following procedure.
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.printButton = new System.Windows.Forms.Button();
this.ClientSize = new System.Drawing.Size(504, 381);
this.Text = "Print Example";
printButton.ImageAlign =
System.Drawing.ContentAlignment.MiddleLeft;
printButton.Location = new System.Drawing.Point(32, 110);
printButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
printButton.TabIndex = 0;
printButton.Text = "Print the file.";
printButton.Size = new System.Drawing.Size(136, 40);
printButton.Click += new System.EventHandler(printButton_Click);
this.Controls.Add(printButton);
}
// This is the main entry point for the application.
public static void Main(string[] args)
{
Application.Run(new PrintingExample());
}
} --------------------编程问答-------------------- 第一 说的太潦草
第二 代码的问题 你懂那些代码吗 根本没基类运行不了的代码... --------------------编程问答-------------------- 楼主,听你口气,怎么觉得别人是在求着你回答你的问题呢 --------------------编程问答-------------------- 报表打印——分组 --------------------编程问答-------------------- 第二 代码的问题 你懂那些代码吗 根本没基类运行不了的代码...
——————————————————————————————
自己看看基类是什么?你自己懂那些代码吗??????
退一万步说,平民也是给你个参考意见
人家好心帮助你,不领情还出言不逊
建议大家别回帖了,让他沉掉 --------------------编程问答-------------------- 这个问题用GDI+解决,不过是小菜一碟,你看不懂别人的例子,和别人不懂你提供的参数格式道理是一样的 --------------------编程问答-------------------- MARK --------------------编程问答-------------------- MARK --------------------编程问答-------------------- 飘过
回帖是一种美德!传说每天回帖即可获得 10 分可用分! --------------------编程问答-------------------- 鄙视楼主!楼主这样的人多了,愿意帮助人的高手的热情也就退了,其他新手也跟着受苦。 --------------------编程问答-------------------- 无视~~~ --------------------编程问答-------------------- 是啊 不过我也做个工资条的东西 郁闷 --------------------编程问答-------------------- 做报表
--------------------编程问答-------------------- 做报表,或者导出Excel --------------------编程问答-------------------- bs还是cs啊 bs可以做个预览界面 js Window.Print();
呵呵
补充:.NET技术 , C#