using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
//-------------------------------------------------------------------------------
// Copyright(C) 2009 CITIZEN SYSTEMS JAPAN CO., LTD. All Rights Reserved.
//-------------------------------------------------------------------------------
// Layout Utilities sample code [[ TestPrint ]] for VCS2008
//
// This program is the basic print sample cord which used a layout file.
// In addition, please understand that error processing is not performed.
//
// The command procedure that is necessary for print is as follows.
//
// [01] Creates the object.
// [02] Opens the layout file. Open
// [03] Initializes the object. BeginPrint
// [04] Gets an index of the frame. InitFrame
// [05] Gets an index of the part in the frame. GetParts
// [06] Modifies the working area in the object. SetPartsData
// [07] Copies the working area to the print area. AddFrame
// [08] Starts the print. DoPrint
// [09] Cancels the work area. EndPrint
// [10] Clears all area in the object. Close
namespace TestPrint
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//-------------------------------------------------------------------------------
// Gets all installed printers name in the OS.
//-------------------------------------------------------------------------------
foreach (string printerName in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
{
comboBox1.Items.Add(printerName);
}
}
private void button1_Click(object sender, EventArgs e)
{
//-------------------------------------------------------------------------------
// Selects a custom layout file. (by common dialog)
//-------------------------------------------------------------------------------
openFileDialog1.InitialDirectory = @"..\..\";
openFileDialog1.RestoreDirectory = true;
openFileDialog1.Title = "Open a CLF file";
openFileDialog1.Filter = "CLF files (*.clf)|*.clf";
openFileDialog1.FileName = "";
if (openFileDialog1.ShowDialog() == DialogResult.OK){
textBox1.Text = openFileDialog1.FileName;
}
}
private void button2_Click(object sender, EventArgs e)
{
//-----------------------------------------------------------------
// Preparations
//-----------------------------------------------------------------
// [01] Creates the object.
Citizen.LayoutUtilities.Printing.Controller clpc = new Citizen.LayoutUtilities.Printing.Controller();
// [02] Opens the layout file.
// Argument : pathName
int result = clpc.Open(textBox1.Text);
// [03] Initializes the object.
// Initializes a result of InitFrame() and AddFrame().
// Argument : None
clpc.BeginPrint();
//-----------------------------------------------------------------
// Modifies a value of "Text1" in "Frame1", and add it to the print area.
//-----------------------------------------------------------------
// [04] Gets an index of the frame.
// Copies the frame to the working area in the object.
// Argument : frameName
int frameIndex = clpc.InitFrame("Frame1");
// [05] Gets an index of the part in the frame.
// Argument : frameIndex, partName
int partsIndex = clpc.GetParts(frameIndex, "Text1");
// [06] Modifies the working area in the object.
// Argument : frameIndex, partIndex, setText
result = clpc.SetPartsData(frameIndex, partsIndex, textBox2.Text);
// [07] Copies the working area to the print area.
// Execute InitFrame() before this processing.
// Argument : frameIndex
result = clpc.AddFrame(frameIndex);
// -----------------------------------------------------------------
// Prints the print area.
// -----------------------------------------------------------------
// [08] Starts the print.
// Execute AddFrame() before this processing.
// Argument : printerName (Blank : The default printer is used to print.)
result = clpc.DoPrint(comboBox1.Text);
// -----------------------------------------------------------------
// Processing of end
// -----------------------------------------------------------------
// [09] Cancels the work area.
// Execute BeginPrint() or Close() after this processing.
// Argument : None
clpc.EndPrint();
// [10] Clears all area in the object.
// Execute Open() after this processing.
// Argument : None
clpc.Close();
}
}
}
ผมลองมาแปลงเป้น vb มันผิดตรงนี้อะคับ
Citizen.LayoutUtilities.Printing.Controller clpc = new Citizen.LayoutUtilities.Printing.Controller();
มาใส่ใน vb เป็นแบบนี้ มันเติมวงเล็บให้เองด้วยคับ
citizen.LayoutUtilities.Printing.Controller (clpc = New CITIZEN.LayoutUtilities.Printing.Controller)