标题:在打印时控制行间距!!
只看楼主
lisir888
Rank: 1
等 级:新手上路
帖 子:259
专家分:0
注 册:2006-8-23
 问题点数:0 回复次数:3 
在打印时控制行间距!!
在打印时控制行间距和对齐方式怎么写啊。谢谢了。
我知道用PrintPageEventArgs.Graphics 最后一个参数来控制。但是那个参数应该怎么写我不会!!

[此贴子已经被作者于2006-10-20 20:20:50编辑过]

搜索更多相关主题的帖子: 间距 打印 参数 Graphics 
2006-10-20 19:56
lisir888
Rank: 1
等 级:新手上路
帖 子:259
专家分:0
注 册:2006-8-23
得分:0 
谁能帮解决一下啊!!
2006-10-21 13:33
jingzhao22visa
Rank: 1
等 级:新手上路
威 望:1
帖 子:343
专家分:0
注 册:2006-8-10
得分:0 

获取用于绘制页的 Graphics

命名空间:System.Drawing.Printing
程序集:System.Drawing(在 system.drawing.dll 中)

语法

Visual Basic(声明)
Public ReadOnly Property Graphics As Graphics

Visual Basic(用法)
Dim instance As PrintPageEventArgs
Dim value As Graphics

value = instance.Graphics

C#
public Graphics Graphics { get; }
C++
public:
property Graphics^ Graphics {
    Graphics^ get ();
}

J#
/** @property */
public Graphics get_Graphics ()

JScript
public function get Graphics () : Graphics

属性值

用于绘制页的 Graphics。

示例

下面的代码示例假定已经在 Form 上创建了一个 Button。示例中的 printButton_Click 方法创建 PrintDocument 类的一个实例,调用 pd_PrintPage 方法,然后打印 pd_PrintPage 方法中指定的 .bmp 文件。若要运行该示例,请更改要打印的位图的路径。

System.ComponentModelSystem.CollectionsSystem.DrawingSystem.Drawing.PrintingSystem.ResourcesSystem.Windows.Forms 命名空间用于此示例。

Visual Basic
复制代码
' Specifies what happens when the user clicks the Button.
Private Sub printButton_Click(sender As Object, e As EventArgs)
    Try
        ' Assumes the default printer.
        Dim pd As New PrintDocument()
        AddHandler pd.PrintPage, AddressOf Me.pd_PrintPage
        pd.Print()
    Catch ex As Exception
        MessageBox.Show("An error occurred while printing", _
            ex.ToString())
    End Try
End Sub    

' Specifies what happens when the PrintPage event is raised.
Private Sub pd_PrintPage(sender As Object, ev As PrintPageEventArgs)
    ' Draw a picture.
    ev.Graphics.DrawImage(Image.FromFile("C:\My Folder\MyFile.bmp"), _
        ev.Graphics.VisibleClipBounds)
    
    ' Indicate that this is the last page to print.
    ev.HasMorePages = False
End Sub


C# 复制代码
// Specifies what happens when the user clicks the Button.
private void printButton_Click(object sender, EventArgs e)
{
try
{
// Assumes the default printer.
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
pd.Print();
}
catch(Exception ex)
{
MessageBox.Show("An error occurred while printing", ex.ToString());
}
}

// Specifies what happens when the PrintPage event is raised.
private void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
// Draw a picture.
ev.Graphics.DrawImage(Image.FromFile("C:\\My Folder\\MyFile.bmp"), ev.Graphics.VisibleClipBounds);

// Indicate that this is the last page to print.
ev.HasMorePages = false;
}

C++
复制代码
private:
   // Specifies what happens when the user clicks the Button.
   void printButton_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      try
      {
         // Assumes the default printer.
         PrintDocument^ pd = gcnew PrintDocument;
         pd->PrintPage += gcnew PrintPageEventHandler( this, &Form1::pd_PrintPage );
         pd->Print();
      }
      catch ( Exception^ ex ) 
      {
         MessageBox::Show( "An error occurred while printing", ex->ToString() );
      }
   }

   // Specifies what happens when the PrintPage event is raised.
   void pd_PrintPage( Object^ /*sender*/, PrintPageEventArgs^ ev )
   {
      // Draw a picture.
      ev->Graphics->DrawImage( Image::FromFile( "C:\\My Folder\\MyFile.bmp" ),
         ev->Graphics->VisibleClipBounds );
      
      // Indicate that this is the last page to print.
      ev->HasMorePages = false;
   }

J#
复制代码
// Specifies what happens when the user clicks the Button.
private void printButton_Click(Object sender, EventArgs e)
{
    try {
        // Assumes the default printer.
        PrintDocument pd = new PrintDocument();
        pd.add_PrintPage(new PrintPageEventHandler(this.pd_PrintPage));
        pd.Print();
    }
    catch (System.Exception ex) {
        MessageBox.Show("An error occurred while printing", ex.ToString());
    }
} //printButton_Click

// Specifies what happens when the PrintPage event is raised.
private void pd_PrintPage(Object sender, PrintPageEventArgs ev)
{
    // Draw a picture.
    ev.get_Graphics().DrawImage(Image.FromFile
        ("C:\\My Folder\\MyFile.bmp"),
        ev.get_Graphics().get_VisibleClipBounds());

    // Indicate that this is the last page to print.
    ev.set_HasMorePages(false);
} //pd_PrintPage

平台

Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

PrintPageEventArgs 类
PrintPageEventArgs 成员

2006-10-23 14:38
jingzhao22visa
Rank: 1
等 级:新手上路
威 望:1
帖 子:343
专家分:0
注 册:2006-8-10
得分:0 
msdn上切的,我也没用过,希望对你有帮助。

2006-10-23 14:38



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-97661-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.461540 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved