|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Drawing.Printing;
using GridPrintPreviewLib;
namespace TestApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
ds.ReadXml("testdata.xml");
this.dataGridView1.ColumnHeadersHeight = 40;
this.dataGridView1.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Sunken;
this.dataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.Red;
this.dataGridView1.DataSource = ds.Tables[0];
this.dataGridView1[2, 2].Style.ForeColor = Color.Red;
this.dataGridView1[2, 2].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
this.dataGridView1[2, 3].Style.BackColor = Color.Cyan;
this.dataGridView1[2, 3].Style.Alignment = DataGridViewContentAlignment.MiddleRight;
for (int i = 0; i < this.dataGridView1.RowCount; i++)
{
dataGridView1[17, i].Style.Alignment = DataGridViewContentAlignment.BottomRight;
dataGridView1[18, i].Style.Alignment = DataGridViewContentAlignment.TopCenter;
}
}
private void button8_Click(object sender, EventArgs e)
{
GridPrintDocument doc = new GridPrintDocument(this.dataGridView1, this.dataGridView1.Font, true);
doc.DocumentName = "Preview Test";
doc.StepForFit = 0.02f;
frmPreviewDialog frmDialog = new frmPreviewDialog();
frmDialog.ShowUnit = PrinterUnit.TenthsOfAMillimeter;
frmDialog.printDocument = doc;
frmDialog.ShowDialog(this);
frmDialog.Dispose();
doc.Dispose();
}
}
}
|
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.
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…