注册 登录
编程论坛 ASP.NET技术论坛

[求助]怎样实现打印预览和打印DataGrid中的数据???

xinghun868 发布于 2007-10-28 22:42, 793 次点击

请教各位大侠~~~~

4 回复
#2
助人为乐2007-10-29 06:50
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;

namespace DataGridPrint
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.DataGrid dgTest;
private System.Windows.Forms.Button btnFillDataGrid;
private System.Windows.Forms.MainMenu mnuFile;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem miPrintPreview;
private System.Windows.Forms.MenuItem miPrint;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem miExit;
private System.Windows.Forms.DataGridTableStyle dgtsCustomers;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn1;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn2;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn3;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn4;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn6;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn7;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn8;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn9;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn10;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn11;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn5;
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
private System.Data.SqlClient.SqlConnection sqlConnection1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
#3
bygg2007-10-29 12:58
可以利用WEB的打印功能来打印页面.也可以把要打印的数据显示在报表中..
#4
菜鳥弎魛2007-10-30 11:16

我以前写过一个这样一来的程序,我是用直接画的方式实现的,是win,如果是web就好办了,就是非颠倒楼的方法

#5
菜鳥弎魛2007-10-30 11:17

不好意思,字打错了 "非颠倒楼"="3楼"

1