如何制作从右到左打印的

如何制作从右到左打印的

本文介绍了如何制作从右到左打印的信息表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
如何制作从右到左打印的DataGridView信息表?





hiHow to make a table of DataGridView information printed right to left?


// The printing setup function
 private bool SetupThePrinting()
 {
     PrintDialog MyPrintDialog = new PrintDialog();
     MyPrintDialog.AllowCurrentPage = false;
     MyPrintDialog.AllowPrintToFile = false;
     MyPrintDialog.AllowSelection = false;
     MyPrintDialog.AllowSomePages = false;
     MyPrintDialog.PrintToFile = false;
     MyPrintDialog.ShowHelp = false;
     MyPrintDialog.ShowNetwork = false;

     if (MyPrintDialog.ShowDialog() != DialogResult.OK)
     return false;

     MyPrintDocument.DocumentName = "Customers Report";
     MyPrintDocument.PrinterSettings =
     MyPrintDialog.PrinterSettings;
     MyPrintDocument.DefaultPageSettings =
     MyPrintDialog.PrinterSettings.DefaultPageSettings;
     MyPrintDocument.DefaultPageSettings.Margins =
     new Margins(40, 40, 40, 40);

     if (MessageBox.Show("Do you want the report to be centered on the page",
            "InvoiceManager - Center on Page", MessageBoxButtons.YesNo,
            MessageBoxIcon.Question) == DialogResult.Yes)
        MyDataGridViewPrinter = new DataGridViewPrinter(MyDataGridView, MyPrintDocument, true, true, "Customers", new Font("Tahoma", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true);
     else
        MyDataGridViewPrinter = new DataGridViewPrinter(MyDataGridView, MyPrintDocument, false, true, "Customers", new Font("Tahoma", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true);

     return true;


 // The Print Button
 private void btnPrint_Click(object sender, EventArgs e)
 {
    if (SetupThePrinting())
    MyPrintDocument.Print();
 }




using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Printing;
using System.Data;
using System.Windows.Forms;

class DataGridViewPrinter
{
   // The DataGridView Control which will be printed
   private DataGridView TheDataGridView;
   // The PrintDocument to be used for printing
   private PrintDocument ThePrintDocument;
   // Determine if the report will be
   // printed in the Top-Center of the page
   private bool IsCenterOnPage;
   // Determine if the page contain title text
   private bool IsWithTitle;
   // The title text to be printed
   // in each page (if IsWithTitle is set to true)
   private string TheTitleText;
   // The font to be used with the title
   // text (if IsWithTitle is set to true)
   private Font TheTitleFont;
   // The color to be used with the title
   // text (if IsWithTitle is set to true)
   private Color TheTitleColor;
   // Determine if paging is used
   private bool IsWithPaging;

   // A static parameter that keep track
   // on which Row (in the DataGridView control)
   // that should be printed
   static int CurrentRow;

   static int PageNumber;

   private int PageWidth;
   private int PageHeight;
   private int LeftMargin;
   private int TopMargin;
   private int RightMargin;
   private int BottomMargin;

   // A parameter that keep track
   // on the y coordinate of the page,
   // so the next object to be printed
   // will start from this y coordinate
   private float CurrentY;

   private float RowHeaderHeight;
   private List RowsHeight;
   private List ColumnsWidth;
   private float TheDataGridViewWidth;

   // Maintain a generic list to hold start/stop
   // points for the column printing
   // This will be used for wrapping
   // in situations where the DataGridView will not
   // fit

   public DataGridViewPrinter(DataGridView aDataGridView, PrintDocument aPrintDocument,
   bool CenterOnPage, bool WithTitle, string aTitleText, Font aTitleFont,
   Color aTitleColor, bool WithPaging)

   // The DataGridView Control which will be printed.
   DataGridView MyDataGridView;
   // The PrintDocument to be used for printing.
   PrintDocument MyPrintDocument;
   // The class that will do the printing process.
   DataGridViewPrinter MyDataGridViewPrinter;

推荐答案

这篇关于如何制作从右到左打印的信息表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 07:52