Click here to Skip to main content
15,893,266 members
Articles / Programming Languages / C#

DataGridView Print/Print Preview Solution - Part II

Rate me:
Please Sign up or sign in to vote.
5.00/5 (15 votes)
18 Jun 2009CPOL4 min read 77.5K   7.4K   47  
This article is the second one of two articles in which I want to show a solution for the Print Preview of the DataGridView object. One of the goals of my solution is to print the DataGridView keeping its styles automatically.
namespace GridPrintPreviewLib
{
    partial class GLFitSettings
    {
        /// <summary> 
        /// Variabile di progettazione necessaria.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary> 
        /// Liberare le risorse in uso.
        /// </summary>
        /// <param name="disposing">ha valore true se le risorse gestite devono essere eliminate, false in caso contrario.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Codice generato da Progettazione componenti

        /// <summary> 
        /// Metodo necessario per il supporto della finestra di progettazione. Non modificare 
        /// il contenuto del metodo con l'editor di codice.
        /// </summary>
        private void InitializeComponent()
        {
            this.rbFitToOne = new System.Windows.Forms.RadioButton();
            this.rbFitToMore = new System.Windows.Forms.RadioButton();
            this.nudHorizontal = new System.Windows.Forms.NumericUpDown();
            this.lblHorizontal = new System.Windows.Forms.Label();
            this.lblVertical = new System.Windows.Forms.Label();
            this.nudVertical = new System.Windows.Forms.NumericUpDown();
            this.rbNormal = new System.Windows.Forms.RadioButton();
            ((System.ComponentModel.ISupportInitialize)(this.nudHorizontal)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.nudVertical)).BeginInit();
            this.SuspendLayout();
            // 
            // rbFitToOne
            // 
            this.rbFitToOne.AutoSize = true;
            this.rbFitToOne.Location = new System.Drawing.Point(4, 24);
            this.rbFitToOne.Name = "rbFitToOne";
            this.rbFitToOne.Size = new System.Drawing.Size(96, 17);
            this.rbFitToOne.TabIndex = 1;
            this.rbFitToOne.Text = "Fit to one page";
            this.rbFitToOne.UseVisualStyleBackColor = true;
            this.rbFitToOne.CheckedChanged += new System.EventHandler(this.rbFitToOne_CheckedChanged);
            // 
            // rbFitToMore
            // 
            this.rbFitToMore.AutoSize = true;
            this.rbFitToMore.Location = new System.Drawing.Point(4, 47);
            this.rbFitToMore.Name = "rbFitToMore";
            this.rbFitToMore.Size = new System.Drawing.Size(106, 17);
            this.rbFitToMore.TabIndex = 2;
            this.rbFitToMore.Text = "Fit to more pages";
            this.rbFitToMore.UseVisualStyleBackColor = true;
            // 
            // nudHorizontal
            // 
            this.nudHorizontal.Location = new System.Drawing.Point(24, 70);
            this.nudHorizontal.Minimum = new decimal(new int[] {
            1,
            0,
            0,
            0});
            this.nudHorizontal.Name = "nudHorizontal";
            this.nudHorizontal.Size = new System.Drawing.Size(38, 20);
            this.nudHorizontal.TabIndex = 3;
            this.nudHorizontal.Value = new decimal(new int[] {
            1,
            0,
            0,
            0});
            this.nudHorizontal.ValueChanged += new System.EventHandler(this.nudHorizontal_ValueChanged);
            // 
            // lblHorizontal
            // 
            this.lblHorizontal.AutoSize = true;
            this.lblHorizontal.Location = new System.Drawing.Point(64, 72);
            this.lblHorizontal.Name = "lblHorizontal";
            this.lblHorizontal.Size = new System.Drawing.Size(86, 13);
            this.lblHorizontal.TabIndex = 4;
            this.lblHorizontal.Text = "Horizontal pages";
            // 
            // lblVertical
            // 
            this.lblVertical.AutoSize = true;
            this.lblVertical.Location = new System.Drawing.Point(64, 101);
            this.lblVertical.Name = "lblVertical";
            this.lblVertical.Size = new System.Drawing.Size(74, 13);
            this.lblVertical.TabIndex = 6;
            this.lblVertical.Text = "Vertical pages";
            // 
            // nudVertical
            // 
            this.nudVertical.Location = new System.Drawing.Point(24, 99);
            this.nudVertical.Minimum = new decimal(new int[] {
            1,
            0,
            0,
            0});
            this.nudVertical.Name = "nudVertical";
            this.nudVertical.Size = new System.Drawing.Size(38, 20);
            this.nudVertical.TabIndex = 5;
            this.nudVertical.Value = new decimal(new int[] {
            1,
            0,
            0,
            0});
            this.nudVertical.ValueChanged += new System.EventHandler(this.nudVertical_ValueChanged);
            // 
            // rbNormal
            // 
            this.rbNormal.AutoSize = true;
            this.rbNormal.Checked = true;
            this.rbNormal.Location = new System.Drawing.Point(4, 3);
            this.rbNormal.Name = "rbNormal";
            this.rbNormal.Size = new System.Drawing.Size(58, 17);
            this.rbNormal.TabIndex = 0;
            this.rbNormal.Text = "Normal";
            this.rbNormal.UseVisualStyleBackColor = true;
            // 
            // GLFitSettings
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Controls.Add(this.rbNormal);
            this.Controls.Add(this.lblVertical);
            this.Controls.Add(this.nudVertical);
            this.Controls.Add(this.lblHorizontal);
            this.Controls.Add(this.nudHorizontal);
            this.Controls.Add(this.rbFitToMore);
            this.Controls.Add(this.rbFitToOne);
            this.Name = "GLFitSettings";
            this.Size = new System.Drawing.Size(154, 130);
            ((System.ComponentModel.ISupportInitialize)(this.nudHorizontal)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.nudVertical)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.RadioButton rbFitToOne;
        private System.Windows.Forms.RadioButton rbFitToMore;
        private System.Windows.Forms.NumericUpDown nudHorizontal;
        private System.Windows.Forms.Label lblHorizontal;
        private System.Windows.Forms.Label lblVertical;
        private System.Windows.Forms.NumericUpDown nudVertical;
        private System.Windows.Forms.RadioButton rbNormal;
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader Mediatech Solutions
Italy Italy
I’m an IT Project Manager for an Italian Betting Company and over the last 2 years I acquired experience in Betting area.
I have developed code in different object oriented languages (C#, C++, Java) for more than 10 years using a set of technology such as .Net, J2EE, multithreading, etc…

Comments and Discussions