科技行者

行者学院 转型私董会 科技行者专题报道 网红大战科技行者

知识库

知识库 安全导航

至顶网软件频道在C#里实现DATAGRID的打印预览和打印(2)

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

  • 扫一扫
    分享文章到微信

  • 扫一扫
    关注官方公众号
    至顶头条

this.dgtsCustomers.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[]

作者:中国IT实验室 来源:中国IT实验室 2007年9月7日

关键字: 打印 打印预览 DataGrid C#

  • 评论
  • 分享微博
  • 分享邮件

this.dgtsCustomers.GridColumnStyles.AddRange(new System.Windows.Forms.DataGridColumnStyle[] {
   this.dataGridTextBoxColumn1,
   this.dataGridTextBoxColumn2,
   this.dataGridTextBoxColumn3,
   this.dataGridTextBoxColumn4,
   this.dataGridTextBoxColumn5,
   this.dataGridTextBoxColumn6,
   this.dataGridTextBoxColumn7,
   this.dataGridTextBoxColumn8,
   this.dataGridTextBoxColumn9,
   this.dataGridTextBoxColumn10,
   this.dataGridTextBoxColumn11});
   this.dgtsCustomers.HeaderForeColor = System.Drawing.SystemColors.ControlText;
   this.dgtsCustomers.MappingName = "Customers";
   this.dgtsCustomers.ReadOnly = true;
   //
   // dataGridTextBoxColumn1
   //
   this.dataGridTextBoxColumn1.Format = "";
   this.dataGridTextBoxColumn1.FormatInfo = null;
   this.dataGridTextBoxColumn1.HeaderText = "Customer Id";
   this.dataGridTextBoxColumn1.MappingName = "CustomerId";
   this.dataGridTextBoxColumn1.NullText = "";
   this.dataGridTextBoxColumn1.Width = 75;
   //
   // dataGridTextBoxColumn2
   //
   this.dataGridTextBoxColumn2.Format = "";
   this.dataGridTextBoxColumn2.FormatInfo = null;
   this.dataGridTextBoxColumn2.HeaderText = "Company Name";
   this.dataGridTextBoxColumn2.MappingName = "CompanyName";
   this.dataGridTextBoxColumn2.NullText = "";
   this.dataGridTextBoxColumn2.Width = 200;
   //
   // dataGridTextBoxColumn3
   //
   this.dataGridTextBoxColumn3.Format = "";
   this.dataGridTextBoxColumn3.FormatInfo = null;
   this.dataGridTextBoxColumn3.HeaderText = "Contact Name";
   this.dataGridTextBoxColumn3.MappingName = "ContactName";
   this.dataGridTextBoxColumn3.NullText = "";
   this.dataGridTextBoxColumn3.Width = 125;
   //
   // dataGridTextBoxColumn4
   //
   this.dataGridTextBoxColumn4.Format = "";
   this.dataGridTextBoxColumn4.FormatInfo = null;
   this.dataGridTextBoxColumn4.HeaderText = "Contact Title";
   this.dataGridTextBoxColumn4.MappingName = "ContactTitle";
   this.dataGridTextBoxColumn4.NullText = "";
   this.dataGridTextBoxColumn4.Width = 170;
   //
   // dataGridTextBoxColumn5
   //
   this.dataGridTextBoxColumn5.Format = "";
   this.dataGridTextBoxColumn5.FormatInfo = null;
   this.dataGridTextBoxColumn5.HeaderText = "Address";
   this.dataGridTextBoxColumn5.MappingName = "Address";
   this.dataGridTextBoxColumn5.NullText = "";
   this.dataGridTextBoxColumn5.Width = 250;
   //
   // dataGridTextBoxColumn6
   //
   this.dataGridTextBoxColumn6.Format = "";
   this.dataGridTextBoxColumn6.FormatInfo = null;
   this.dataGridTextBoxColumn6.HeaderText = "City";
   this.dataGridTextBoxColumn6.MappingName = "City";
   this.dataGridTextBoxColumn6.NullText = "";
   this.dataGridTextBoxColumn6.Width = 150;
   //
   // dataGridTextBoxColumn7
   //
   this.dataGridTextBoxColumn7.Format = "";
   this.dataGridTextBoxColumn7.FormatInfo = null;
   this.dataGridTextBoxColumn7.HeaderText = "Region";
   this.dataGridTextBoxColumn7.MappingName = "Region";
   this.dataGridTextBoxColumn7.NullText = "";
   this.dataGridTextBoxColumn7.Width = 150;

 //
   // dataGridTextBoxColumn8
   //
   this.dataGridTextBoxColumn8.Format = "";
   this.dataGridTextBoxColumn8.FormatInfo = null;
   this.dataGridTextBoxColumn8.HeaderText = "Postal Code";
   this.dataGridTextBoxColumn8.MappingName = "PostalCode";
   this.dataGridTextBoxColumn8.NullText = "";
   this.dataGridTextBoxColumn8.Width = 150;
   //
   // dataGridTextBoxColumn9
   //
   this.dataGridTextBoxColumn9.Format = "";
   this.dataGridTextBoxColumn9.FormatInfo = null;
   this.dataGridTextBoxColumn9.HeaderText = "Country";
   this.dataGridTextBoxColumn9.MappingName = "Country";
   this.dataGridTextBoxColumn9.NullText = "";
   this.dataGridTextBoxColumn9.Width = 125;
   //
   // dataGridTextBoxColumn10
   //
   this.dataGridTextBoxColumn10.Format = "";
   this.dataGridTextBoxColumn10.FormatInfo = null;
   this.dataGridTextBoxColumn10.HeaderText = "Phone";
   this.dataGridTextBoxColumn10.MappingName = "Phone";
   this.dataGridTextBoxColumn10.NullText = "";
   this.dataGridTextBoxColumn10.Width = 125;
   //
   // dataGridTextBoxColumn11
   //
   this.dataGridTextBoxColumn11.Format = "";
   this.dataGridTextBoxColumn11.FormatInfo = null;
   this.dataGridTextBoxColumn11.HeaderText = "Fax";
   this.dataGridTextBoxColumn11.MappingName = "Fax";
   this.dataGridTextBoxColumn11.NullText = "";
   this.dataGridTextBoxColumn11.Width = 125;
   //
   // btnFillDataGrid
   //
   this.btnFillDataGrid.Anchor = (System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right);
   this.btnFillDataGrid.Location = new System.Drawing.Point(645, 426);
   this.btnFillDataGrid.Name = "btnFillDataGrid";
   this.btnFillDataGrid.Size = new System.Drawing.Size(133, 28);
   this.btnFillDataGrid.TabIndex = 2;
   this.btnFillDataGrid.Text = "&Fill DataGrid";
   this.btnFillDataGrid.Click += new System.EventHandler(this.btnFillDataGrid_Click);
   //
   // mnuFile
   //
   this.mnuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
   this.menuItem1});
   //
   // menuItem1
   //
   this.menuItem1.Index = 0;
   this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
   this.miPrintPreview,
   this.miPrint,
   this.menuItem4,
   this.miExit});
   this.menuItem1.Text = "&File";
   //
   // miPrintPreview
   //
   this.miPrintPreview.Index = 0;
   this.miPrintPreview.Text = "Print Pre&view";
   this.miPrintPreview.Click += new System.EventHandler(this.miPrintPreview_Click);
   //
   // miPrint
   //
   this.miPrint.Index = 1;
   this.miPrint.Text = "&Print";
   this.miPrint.Click += new System.EventHandler(this.miPrint_Click);
   //
   // menuItem4
   //
   this.menuItem4.Index = 2;
   this.menuItem4.Text = "-";
   //
   // miExit
   //
   this.miExit.Index = 3;
   this.miExit.Text = "E&xit";
   this.miExit.Click += new System.EventHandler(this.miExit_Click);
   //
   // sqlDataAdapthttp://dotnet.chinaitlab.com/CSharp/721460_3.htmler1
   //
   this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
   this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
   this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
   this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
   new System.Data.Common.DataTableMapping("Table", "Customers", new System.Data.Common.DataColumnMapping[] {
   new System.Data.Common.DataColumnMapping("CustomerID", "CustomerID"),
   new System.Data.Common.DataColumnMapping("CompanyName", "CompanyName"),
   new System.Data.Common.DataColumnMapping("ContactName", "ContactName"),
   new System.Data.Common.DataColumnMapping("ContactTitle", "ContactTitle"),
   new System.Data.Common.DataColumnMapping("Address", "Address"),
   new System.Data.Common.DataColumnMapping("City", "City"),
   new System.Data.Common.DataColumnMapping("Region", "Region"),
   new System.Data.Common.DataColumnMapping("PostalCode", "PostalCode"),
   new System.Data.Common.DataColumnMapping("Country", "Country"),
   new System.Data.Common.DataColumnMapping("Phone", "Phone"),
   new System.Data.Common.DataColumnMapping("Fax", "Fax")})});
   this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
   //
   // sqlSelectCommand1

查看本文来源

    • 评论
    • 分享微博
    • 分享邮件
    邮件订阅

    如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。

    重磅专题
    往期文章
    最新文章