首页 | 互联网 | 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教育

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

 ·算法分析与设计之五大常用算法
 ·开发必备 漫谈Java加密保护
 ·嵌入式开发--ARM技术专题
 ·C/C++指针,认真了解,灵活运用
 ·.NET开发:C#实用基础教程
 ·软件测试工具QTP学习专题
 ·嵌入式开发单片机解决方案专题
 ·Java开发环境 Greenfoot 程序员手册
 ·C++对象布局及多态实现的探索
 ·常见排序算法的实现
 今日更新
 社区讨论
 博客论点
 频道精选
 Dotnet频道相关导航