Margins.Right プロパティ
右端余白を 1/100 インチ単位で取得または設定します。
Public Property Right As Integer
[C#]
public int Right {get; set;}
[C++]
public: __property int get_Right();public: __property void set_Right(int);
[JScript]
public function get Right() : int;public function set Right(int);
プロパティ値
右端余白 (1/100 インチ単位)。
例外
例外の種類 | 条件 |
---|---|
ArgumentException | Right プロパティは、0 未満の値が設定されています。 |
使用例
[Visual Basic, C#, C++] この例では、 System.Drawing 、 System.Drawing.Printing 、および System.IO の各名前空間を使用します。
[Visual Basic, C#, C++] ドキュメントの既定のページ設定を左右の余白 1 インチ、上下の余白 1.5 インチに設定する例を次に示します。
Public Sub Printing()
Try
' This assumes that a variable of type string, named filePath,
' has been set to the path of the file to print.
streamToPrint = New StreamReader(filePath)
Try
printFont = New Font("Arial", 10)
Dim pd As New PrintDocument()
' This assumes that a method, named pd_PrintPage, has been
' defined. pd_PrintPage handles the PrintPage event.
AddHandler pd.PrintPage, AddressOf pd_PrintPage
' This assumes that a variable of type string, named
' printer, has been set to the printer's name.
pd.PrinterSettings.PrinterName = printer
' Set the left and right margins to 1 inch.
pd.DefaultPageSettings.Margins.Left = 100
pd.DefaultPageSettings.Margins.Right = 100
' Set the top and bottom margins to 1.5 inches.
pd.DefaultPageSettings.Margins.Top = 150
pd.DefaultPageSettings.Margins.Bottom = 150
pd.Print()
Finally
streamToPrint.Close()
End Try
Catch ex As Exception
MessageBox.Show("An error occurred printing the file - " & ex.Message)
End Try
End Sub
[C#]
public void Printing()
{
try
{
/* This assumes that a variable of type string, named filePath,
has been set to the path of the file to print. */
streamToPrint = new StreamReader (filePath);
try
{
printFont = new Font("Arial", 10);
PrintDocument pd = new PrintDocument();
/* This assumes that a method, named pd_PrintPage, has been
defined. pd_PrintPage handles the PrintPage event. */
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
/* This assumes that a variable of type string, named
printer, has been set to the printer's name. */
pd.PrinterSettings.PrinterName = printer;
// Set the left and right margins to 1 inch.
pd.DefaultPageSettings.Margins.Left = 100;
pd.DefaultPageSettings.Margins.Right = 100;
// Set the top and bottom margins to 1.5 inches.
pd.DefaultPageSettings.Margins.Top = 150;
pd.DefaultPageSettings.Margins.Bottom = 150;
pd.Print();
}
finally
{
streamToPrint.Close() ;
}
}
catch(Exception ex)
{
MessageBox.Show("An error occurred printing the file - " + ex.Message);
}
}
[C++]
public:
void Printing()
{
try
{
/* This assumes that a variable of type string, named filePath,
has been set to the path of the file to print. */
streamToPrint = new StreamReader (filePath);
try
{
printFont = new System::Drawing::Font(S"Arial", 10);
PrintDocument* pd = new PrintDocument();
/* This assumes that a method, named pd_PrintPage, has been
defined. pd_PrintPage handles the PrintPage event. */
pd->PrintPage += new PrintPageEventHandler(this, &Sample::pd_PrintPage);
/* This assumes that a variable of type string, named
printer, has been set to the printer's name. */
pd->PrinterSettings->PrinterName = printer;
// Set the left and right margins to 1 inch.
pd->DefaultPageSettings->Margins->Left = 100;
pd->DefaultPageSettings->Margins->Right = 100;
// Set the top and bottom margins to 1.5 inches.
pd->DefaultPageSettings->Margins->Top = 150;
pd->DefaultPageSettings->Margins->Bottom = 150;
pd->Print();
}
__finally
{
streamToPrint->Close() ;
}
}
catch(Exception* ex)
{
MessageBox::Show(String::Concat( S"An error occurred printing the file - ", ex->Message ));
}
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
Margins クラス | Margins メンバ | System.Drawing.Printing 名前空間 | Left | Top | Bottom