本文整理汇总了C#中System.Drawing.Printing.PrintDocument.Print方法的典型用法代码示例。如果您正苦于以下问题:C# System.Drawing.Printing.PrintDocument.Print方法的具体用法?C# System.Drawing.Printing.PrintDocument.Print怎么用?C# System.Drawing.Printing.PrintDocument.Print使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Printing.PrintDocument
的用法示例。
在下文中一共展示了System.Drawing.Printing.PrintDocument.Print方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Print
public virtual void Print()
{
System.Drawing.Printing.PrintDocument printDocument = new System.Drawing.Printing.PrintDocument();
printDocument.PrinterSettings.PrinterName = this.m_PrintQueue.FullName;
printDocument.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintDocument_PrintPage);
printDocument.Print();
}
示例2: TmrPrint_Tick
private void TmrPrint_Tick(object sender, EventArgs e)
{
pnlPrint.Visible = false;
TmrPrint.Enabled = false;
using (System.Drawing.Printing.PrintDocument printDocument = new System.Drawing.Printing.PrintDocument())
{
printDocument.PrintPage += printDocument_PrintPage;
CaptureScreen();
try
{
PrintDialog dlg = new PrintDialog();
dlg.Document = printDocument;
dlg.PrinterSettings.Copies = 3;
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
printDocument.PrinterSettings = dlg.PrinterSettings;
printDocument.Print();
}
else
{
pnlPrint.Visible = true;
return;
}
}
catch (Exception ex)
{ MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,MessageBoxIcon.Error); }
}
Close();
pnlPrint.Visible = true;
}
示例3: btnin_Click
private void btnin_Click(object sender, EventArgs e)
{
if(issave == false)
{
if(MessageBox.Show("Bạn phải lưu trước khi in, lưu ngay?", "Thông báo", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
btnluu.PerformClick();
System.Drawing.Printing.PrintDocument myPrintDocument1 = new System.Drawing.Printing.PrintDocument();
PrintDialog myPrinDialog1 = new PrintDialog();
myPrintDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(myPrintDocument2_PrintPage);
myPrinDialog1.Document = myPrintDocument1;
if (myPrinDialog1.ShowDialog() == DialogResult.OK)
{
myPrintDocument1.Print();
MessageBox.Show("In phiếu đặt chỗ thành công!", "Thông báo");
}
}
else
{
System.Drawing.Printing.PrintDocument myPrintDocument1 = new System.Drawing.Printing.PrintDocument();
PrintDialog myPrinDialog1 = new PrintDialog();
myPrintDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(myPrintDocument2_PrintPage);
myPrinDialog1.Document = myPrintDocument1;
if (myPrinDialog1.ShowDialog() == DialogResult.OK)
{
myPrintDocument1.Print();
MessageBox.Show("In phiếu đặt chỗ thành công!", "Thông báo");
}
}
}
}
示例4: btnin_Click
private void btnin_Click(object sender, EventArgs e)
{
System.Drawing.Printing.PrintDocument myPrintDocument1 = new System.Drawing.Printing.PrintDocument();
PrintDialog myPrinDialog1 = new PrintDialog();
myPrintDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(myPrintDocument2_PrintPage);
myPrinDialog1.Document = myPrintDocument1;
if (myPrinDialog1.ShowDialog() == DialogResult.OK)
{
myPrintDocument1.Print();
MessageBox.Show("In báo cáo thành công!", "Thông báo");
}
}
示例5: cmdPrintToPrinter_Click
private void cmdPrintToPrinter_Click(object sender, EventArgs e)
{
System.Drawing.Printing.PrintDocument printdoc = new System.Drawing.Printing.PrintDocument();
printdoc.PrintPage += (e2, s2) =>
{
var g = s2.Graphics;
var canvasInit = new PixelFarm.Drawing.CanvasInitParameters();
canvasInit.externalCanvas = g;
var canvas = LayoutFarm.UI.GdiPlus.MyWinGdiPortal.P.CreateCanvas(0, 0, 800, 600, canvasInit);
vwport.PrintMe((PixelFarm.Drawing.WinGdi.MyGdiPlusCanvas)canvas);
};
printdoc.Print();
}
示例6: buttonImprimir_Click
private void buttonImprimir_Click(object sender, EventArgs e)
{
//using (var printDocument = new System.Drawing.Printing.PrintDocument())
//{
// printDocument.PrintPage += printDocument_PrintPage;
// printDocument.PrinterSettings.PrinterName = comboBoxImpressoras.SelectedItem.ToString();
// printDocument.Print();
//}
using (var printDocument = new System.Drawing.Printing.PrintDocument())
{
printDocument.PrintPage += printDocument_PrintPage;
printDocument.PrinterSettings.PrinterName = comboBoxImpressoras.SelectedItem.ToString();
_texto = textBoxImpressao.Text;
printDocument.Print();
}
}
示例7: TmrPrint_Tick
private void TmrPrint_Tick(object sender, EventArgs e)
{
TmrPrint.Enabled = false;
using (System.Drawing.Printing.PrintDocument printDocument = new System.Drawing.Printing.PrintDocument())
{
printDocument.PrintPage += printDocument_PrintPage;
CaptureScreen();
try
{ printDocument.Print(); }
catch (Exception ex)
{ MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,MessageBoxIcon.Error); }
}
Close();
}
示例8: PrintTicket
private void PrintTicket()
{
System.Drawing.Printing.PrintDocument doc = new System.Drawing.Printing.PrintDocument();
System.Drawing.Printing.PageSettings ps = new System.Drawing.Printing.PageSettings();
doc.DocumentName = "tiket.pdf";
doc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(doc_PrintPage);
doc.Print();
}
示例9: button12_Click
private void button12_Click(object sender, EventArgs e)
{
if (Statistics.Columns.Count == 3)
{
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;
pd = new System.Drawing.Printing.PrintDocument();
pd.DocumentName = "������ �����";
//pd.PrinterSettings = MyPrintDialog.PrinterSettings;
pd.DefaultPageSettings = pd.PrinterSettings.DefaultPageSettings;
pd.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(20, 20, 20, 20);
pd.DefaultPageSettings.Landscape = false;
pd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(pd_PrintPage);
string tit = "���������� ����������/��������� \n�� ������ � "+MyDateSpan.start.ToShortDateString() + " �� " + MyDateSpan.end.ToShortDateString() + ".";
prin = new DataGridViewPrinter(Statistics, pd, true, true, tit, new Font("Tahoma", 18), Color.Black, false);
pd.Print();
}
else
{
//����������� ����������
ListSortDirection SO = ListSortDirection.Ascending;
dgw2 = new DataGridView();
//DataGridViewRow[] arr = new DataGridViewRow[Statistics.SelectedRows.Count];
DataGridViewColumn[] arr1 = new DataGridViewColumn[Statistics.Columns.Count];
//Statistics.SelectedRows.CopyTo(arr, 0);
Statistics.Columns.CopyTo(arr1, 0);
dgw2.AutoGenerateColumns = false;
dgw2.Columns.Clear();
dgw2.Font = new Font("Times New Roman", 10);
//dgw2.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
//dgw2.RowTemplate.DefaultCellStyle.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
//dgw2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dgw2.AllowUserToAddRows = false;
//dgw2.Columns.AddRange(arr1);
foreach (DataGridViewColumn col in arr1)
{
//dgw2.Columns.Add((DataGridViewColumn)col.Clone());
dgw2.Columns.Add("","");
}
int i = 0;
for (int ri = 0; ri < Statistics.Rows.Count; ri++)
{
dgw2.Rows.Add();// (DataGridViewRow)Statistics.SelectedRows[ri].Clone();
DataGridViewRow clonedRow = dgw2.Rows[i];
for (Int32 index = 0; index < Statistics.Rows[ri].Cells.Count; index++)
{
dgw2.Rows[i].Cells[index].Value = Statistics.Rows[ri].Cells[index].Value;
}
//dgw2.Rows.Add(clonedRow);
i++;
}
dgw2.AutoSize = false;
dgw2.RowTemplate.DefaultCellStyle.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
dgw2.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.True;
dgw2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dgw2.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
//Statistics.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None;
dgw2.Columns[0].Width = 35;
dgw2.Columns[1].Width = 470;
dgw2.Columns[2].Width = 215;
dgw2.Columns[2].Visible = true;
dgw2.Columns[3].Width = 70;
dgw2.Columns[4].Visible = false;
dgw2.Columns[5].Visible = false;
dgw2.Columns[6].Visible = false;
dgw2.Columns[7].Width = 70;
dgw2.Columns[8].Width = 100;
dgw2.Columns[9].Visible = false;
dgw2.Columns[10].Width = 70;
dgw2.Columns[11].Width = 70;
dgw2.Columns[1].HeaderText = "��������";
dgw2.Columns[2].HeaderText = "�����";
dgw2.Columns[3].HeaderText = "���. �����";
dgw2.Columns[4].HeaderText = "��������������";
dgw2.Columns[7].HeaderText = "����� ������";
dgw2.Columns[8].HeaderText = "���";
dgw2.Columns[10].HeaderText = "���� ������";
dgw2.Columns[10].ValueType = typeof(DateTime);
dgw2.Columns[11].HeaderText = "���� ��������";
if (Statistics.SortedColumn != null)
{
if (Statistics.Columns[Statistics.SortedColumn.Index].HeaderCell.SortGlyphDirection == System.Windows.Forms.SortOrder.Ascending)
{
SO = ListSortDirection.Ascending;
}
if (Statistics.Columns[Statistics.SortedColumn.Index].HeaderCell.SortGlyphDirection == System.Windows.Forms.SortOrder.Descending)
{
SO = ListSortDirection.Descending;
}
dgw2.Sort(dgw2.Columns[Statistics.SortedColumn.Index], SO);
//.........这里部分代码省略.........
示例10: Imprimir
/// <summary>
/// Imprime la lista de Pacientes
/// </summary>
private void Imprimir()
{
try
{
//imprimir a un archivo: System.IO.StreamReader streamToPrint = new System.IO.StreamReader("C:\\Archivo.txt");
try
{
System.Drawing.Printing.PrintDocument oPrintDocument = new System.Drawing.Printing.PrintDocument();
oPrintDocument.DocumentName = "Pacientes";
oPrintDocument.Print();
}
finally
{
//streamToPrint.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
示例11:
private void 印刷ToolStripMenuItem_Click(object sender, EventArgs e)
{
System.Drawing.Printing.PrintDocument pd =
new System.Drawing.Printing.PrintDocument();
pd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(print_template.print_system_barcode);
pd.Print();
}
示例12: printImage
/// <summary>
/// Print an image
/// David
/// TODO: Make it work properly with a print dialog
/// </summary>
/// <param name="filePath">path to image to print</param>
public static void printImage(string filePath)
{
printImagePath = filePath;
System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument();
pd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintImage);
pd.Print();
}
示例13: Print_Click
public void Print_Click(object sender, System.EventArgs args)
{
System.Drawing.Printing.PrintDocument doc = new System.Drawing.Printing.PrintDocument();
doc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(doc_PrintPage);
doc.Print();
}
示例14: printStock
private void printStock(ref int labelID)
{
int mm = 0;
int lline = 0;
object frmBarcodedesign = null;
string sql = null;
System.Drawing.Printing.PrintDocument Printer = new System.Drawing.Printing.PrintDocument();
System.Drawing.Printing.PrintDocument lObject = new System.Drawing.Printing.PrintDocument();
int y = 0;
ADODB.Recordset rs = default(ADODB.Recordset);
ADODB.Recordset rsData = default(ADODB.Recordset);
lObject = Printer;
int currentPic = 0;
string lString1 = null;
string lString2 = null;
//Set rsData = getRS("SELECT * FROM BClabelItem INNER JOIN BClabel ON BClabelItem.BClabelItem_BCLabelID = BClabel.BClabelID Where (((BClabel.BClabelID) = " & labelID & ")) ORDER BY BClabel.BClabelID, BClabelItem.BClabelItem_Line;")
rsData = modRecordSet.getRS(ref "SELECT * FROM BClabelItem INNER JOIN BClabel ON BClabelItem.BClabelItem_BCLabelID = BClabel.BClabelID Where (((BClabel.BClabelID) = " + labelID + ")) And ((BClabelItem.BClabelItem_Disabled) <> True) ORDER BY BClabel.BClabelID, BClabelItem.BClabelItem_Line;");
sql = "SELECT StockItem.StockItemID, Catalogue.Catalogue_Quantity, StockItem.StockItem_Name, Catalogue.Catalogue_Barcode, Supplier.SupplierID, Supplier.Supplier_Name, PricingGroup.PricingGroupID, PricingGroup.PricingGroup_Name, Format([CatalogueChannelLnk_Price],'Currency') AS Price, barcodePersonLnk.barcodePersonLnk_PersonID, barcodePersonLnk.barcodePersonLnk_PrintQTY, Company.*";
sql = sql + "FROM Company, barcodePersonLnk INNER JOIN ((((StockItem INNER JOIN Supplier ON StockItem.StockItem_SupplierID = Supplier.SupplierID) INNER JOIN PricingGroup ON StockItem.StockItem_PricingGroupID = PricingGroup.PricingGroupID) INNER JOIN Catalogue ON StockItem.StockItemID = Catalogue.Catalogue_StockItemID) INNER JOIN CatalogueChannelLnk ON (Catalogue.Catalogue_Quantity = CatalogueChannelLnk.CatalogueChannelLnk_Quantity) AND (Catalogue.Catalogue_StockItemID = CatalogueChannelLnk.CatalogueChannelLnk_StockItemID)) ON (barcodePersonLnk.barcodePersonLnk_StockItemID = Catalogue.Catalogue_StockItemID) AND (barcodePersonLnk.barcodePersonLnk_Shrink = Catalogue.Catalogue_Quantity)";
sql = sql + "WHERE (((barcodePersonLnk.barcodePersonLnk_PersonID)=1) AND ((barcodePersonLnk.barcodePersonLnk_PrintQTY)<>0) AND ((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID)=1));";
sql = "SELECT StockItem.StockItemID, Catalogue.Catalogue_Quantity, StockItem.StockItem_Name, Catalogue.Catalogue_Barcode, Supplier.SupplierID, Supplier.Supplier_Name, PricingGroup.PricingGroupID, PricingGroup.PricingGroup_Name, Format([CatalogueChannelLnk_Price],'Currency') AS Price, barcodePersonLnk.barcodePersonLnk_PersonID, barcodePersonLnk.barcodePersonLnk_PrintQTY, Company.*, barcodePersonLnk.barcodePersonLnk_PrintQTY ";
sql = sql + "FROM Company, barcodePersonLnk INNER JOIN ((((StockItem INNER JOIN Supplier ON StockItem.StockItem_SupplierID = Supplier.SupplierID) INNER JOIN PricingGroup ON StockItem.StockItem_PricingGroupID = PricingGroup.PricingGroupID) INNER JOIN Catalogue ON StockItem.StockItemID = Catalogue.Catalogue_StockItemID) INNER JOIN CatalogueChannelLnk ON (Catalogue.Catalogue_StockItemID = CatalogueChannelLnk.CatalogueChannelLnk_StockItemID) AND (Catalogue.Catalogue_Quantity = CatalogueChannelLnk.CatalogueChannelLnk_Quantity)) ON (barcodePersonLnk.barcodePersonLnk_Shrink = Catalogue.Catalogue_Quantity) AND (barcodePersonLnk.barcodePersonLnk_StockItemID = Catalogue.Catalogue_StockItemID) ";
sql = sql + "WHERE (((barcodePersonLnk.barcodePersonLnk_PersonID)=1) AND ((barcodePersonLnk.barcodePersonLnk_PrintQTY)<>0) AND ((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID)=1));";
gLBLleft = (lObject.PrinterSettings.DefaultPageSettings.PaperSize.Width - (gLBLwidth)) / 2 + (gOffsetLabel * twipsToMM);
// lObject.Cls
//gLBLleft = (Printer.Width - gLBLwidth) + ((gOffsetLabel) * frmBarcodedesign.twipsToMM)
rs = modRecordSet.getRS(ref sql);
while (!(rs.EOF)) {
rsData.MoveFirst();
y = Convert.ToInt16((gLBLheight - rsData.Fields("BClabel_Height").Value * twipsToMM) / 2);
Printer.PrinterSettings.Copies = rs.Fields("barcodePersonLnk_PrintQTY").Value;
if (y < 0)
y = 0;
//lObject.FontName = "Tahoma"
rsData.MoveFirst();
if (rsData.RecordCount) {
lline = rsData.Fields("BClabelItem_Line").Value;
while (!(rsData.EOF)) {
if (lline != rsData.Fields("BClabelItem_Line").Value) {
//y = lObject.Location.Y + 10
lline = rsData.Fields("BClabelItem_Line").Value;
}
switch (Strings.LCase(rsData.Fields("BClabelItem_Field").Value)) {
case "line":
break;
//lObject.Line((15 + gLBLleft, y) - (gLBLleft + gLBLwidth, y), System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black))
case "code":
switch (rsData.Fields("BClabelItem_Align").Value) {
case 1:
printBarcode(lObject, rs.Fields("Catalogue_Barcode").Value, gLBLleft + 90, y);
break;
case 2:
printBarcode(lObject, rs.Fields("Catalogue_Barcode").Value, gLBLleft + 90, y);
break;
default:
printBarcode(ref lObject, ref rs.Fields("Catalogue_Barcode").Value, ref gLBLleft, ref y, ref gLBLwidth);
break;
}
break;
default:
//lObject.FontSize = rsData.Fields("BClabelItem_Size").Value
//lObject.FontBold = rsData.Fields("BClabelItem_Bold").Value
//lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.White)
mm = rsData.Fields("BClabelItem_Field").Value;
lString1 = rs.Fields(mm).Value;
switch (rsData.Fields("BClabelItem_Align").Value) {
case 1:
break;
//lObject.PSet(New Point[](gLBLleft + 90, y))
//lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
//lObject.Print(lString1)
case 2:
break;
//lObject.PSet(New Point[](gLBLleft + gLBLwidth - lObject.TextWidth(lString1) - 90, y))
//lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
//lObject.Print(lString1)
case 3:
//splitString(lObject, lString1, lString2)
if (!string.IsNullOrEmpty(lString1)) {
//lObject.PSet(New Point[](CShort(gLBLleft + (gLBLwidth - lObject.TextWidth(lString1)) / 2), y))
//lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
//lObject.Print(lString1)
//y = lObject.Location.Y + 10
//lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.White)
}
lString1 = lString2;
if (!string.IsNullOrEmpty(lString1)) {
//lObject.PSet(New Point[](CShort(gLBLleft + (gLBLwidth - lObject.TextWidth(lString1)) / 2), y))
//lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
//lObject.Print(lString1)
}
//.........这里部分代码省略.........
示例15: PrintScreen
/// <summary>
/// Print image of form via current printer
/// </summary>
/// <param name="form">form</param>
private void PrintScreen(Form form)
{
//this.printedBitmap = new Bitmap(form.Width, form.Height);
//form.DrawToBitmap(this.printedBitmap, new Rectangle(0, 0, form.Width, form.Height));
this.printedBitmap = CaptureControl(form);
var pd = new System.Drawing.Printing.PrintDocument();
pd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(pd_PrintPage);
pd.DefaultPageSettings.Landscape = true;
pd.Print();
}