首页 | 互联网 | IT动态 | IT培训 | Cisco | Windows | Linux | Java | .Net | Oracle | 软件测试 | C/C++ | 嵌入式开发 | 存储世界 | 服务器
网络设备 | IDC | 安全 | 求职招聘 | 数字网校 | 笔记本电脑 | 北大青鸟 | 技术专题 | 电子书下载 | 教学视频 | 源码下载 | 搜索 | 博客 | 论坛
中国IT实验室Dotnet频道
中国IT教育
Google
首页 ASP.NET  C#  XML/WebService ADO.NET VC.NET VB.NET .NET 资讯动态 专题 RSS订阅 讨论 下载
您现在的位置: 中国IT实验室 >> Dotnet >> C# >> 正文

在C#里实现DATAGRID的打印预览和打印

     很多人都在论坛里问,如何实现DATAGRID的打印预览和打印,现在我就把这方面的源代码告诉大家。这段代码也花费了我1个晚上的时间,呵呵!数据库是基于sql server2000自带的northwind。源代码如下:
  
  using System;
  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();

[1] [2] [3] [4] [5] [6] [7] 下一页

【责编:Youping】

中国IT教育

相关产品和培训
文章评论
 友情推荐链接
 认证培训
 专题推荐

 ·开源软件测试工具学习专题
 ·JSP Web开发 入门基础到高手进阶教程…
 ·JavaFX—是Java桌面的新希望么?
 ·安全至上 .NET开发安全策略…
 ·测试用例设计之道-测试用例学习专题
 ·面向Java开发人员的Scala指南
 ·Java设计模式之实例详解
 ·Oracle数据库11g 面向DBA和开发人员的重要新特性…
 ·桌面应用软件编程 J2SE技术详解…
 ·我“炫”我精彩-------WPF开发教程
 今日更新
 社区讨论
 博客论点
 频道精选
 Dotnet频道相关导航