StringFormat.Alignment プロパティ
アセンブリ: System.Drawing (system.drawing.dll 内)

Dim instance As StringFormat Dim value As StringAlignment value = instance.Alignment instance.Alignment = value
public: property StringAlignment Alignment { StringAlignment get (); void set (StringAlignment value); }
/** @property */ public StringAlignment get_Alignment () /** @property */ public void set_Alignment (StringAlignment value)
public function get Alignment () : StringAlignment public function set Alignment (value : StringAlignment)
テキスト配置情報を指定する StringAlignment 列挙体。

LineAlignment プロパティと Alignment プロパティ、および StringAlignment 列挙体を使用して、文字列を配置する方法を次のコード例に示します。この例は、Windows フォームでの使用を意図してデザインされています。コードをフォームに貼り付け、フォームの Paint イベントを処理するときに PaintEventArgs の e を渡して ShowLineAndAlignment メソッドを呼び出します。
Private Sub ShowLineAndAlignment(ByVal e As PaintEventArgs) ' Construct a new Rectangle. Dim displayRectangle _ As New Rectangle(New Point(40, 40), New Size(80, 80)) ' Construct two new StringFormat objects Dim format1 As New StringFormat(StringFormatFlags.NoClip) Dim format2 As New StringFormat(format1) ' Set the LineAlignment and Alignment properties for ' both StringFormat objects to different values. format1.LineAlignment = StringAlignment.Near format1.Alignment = StringAlignment.Center format2.LineAlignment = StringAlignment.Center format2.Alignment = StringAlignment.Far ' Draw the bounding rectangle and a string for each ' StringFormat object. e.Graphics.DrawRectangle(Pens.Black, displayRectangle) e.Graphics.DrawString("Showing Format1", Me.Font, Brushes.Red, _ RectangleF.op_Implicit(displayRectangle), format1) e.Graphics.DrawString("Showing Format2", Me.Font, Brushes.Red, _ RectangleF.op_Implicit(displayRectangle), format2) End Sub
private void ShowLineAndAlignment(PaintEventArgs e) { // Construct a new Rectangle . Rectangle displayRectangle = new Rectangle (new Point(40, 40), new Size (80, 80)); // Construct 2 new StringFormat objects StringFormat format1 = new StringFormat(StringFormatFlags.NoClip); StringFormat format2 = new StringFormat(format1); // Set the LineAlignment and Alignment properties for // both StringFormat objects to different values. format1.LineAlignment = StringAlignment.Near; format1.Alignment = StringAlignment.Center; format2.LineAlignment = StringAlignment.Center; format2.Alignment = StringAlignment.Far; // Draw the bounding rectangle and a string for each // StringFormat object. e.Graphics.DrawRectangle(Pens.Black, displayRectangle); e.Graphics.DrawString("Showing Format1", this.Font, Brushes.Red, (RectangleF)displayRectangle, format1); e.Graphics.DrawString("Showing Format2", this.Font, Brushes.Red, (RectangleF)displayRectangle, format2); }
private: void ShowLineAndAlignment( PaintEventArgs^ e ) { // Construct a new Rectangle . Rectangle displayRectangle = Rectangle(Point(40,40),System::Drawing::Size( 80, 80 )); // Construct 2 new StringFormat objects StringFormat^ format1 = gcnew StringFormat( StringFormatFlags::NoClip ); StringFormat^ format2 = gcnew StringFormat( format1 ); // Set the LineAlignment and Alignment properties for // both StringFormat objects to different values. format1->LineAlignment = StringAlignment::Near; format1->Alignment = StringAlignment::Center; format2->LineAlignment = StringAlignment::Center; format2->Alignment = StringAlignment::Far; // Draw the bounding rectangle and a string for each // StringFormat object. e->Graphics->DrawRectangle( Pens::Black, displayRectangle ); e->Graphics->DrawString( "Showing Format1", this->Font, Brushes::Red, displayRectangle, format1 ); e->Graphics->DrawString( "Showing Format2", this->Font, Brushes::Red, displayRectangle, format2 ); }
private void ShowLineAndAlignment(PaintEventArgs e) { // Construct a new Rectangle . Rectangle displayRectangle = new Rectangle(new Point(40, 40), new Size(80, 80)); // Construct 2 new StringFormat objects StringFormat format1 = new StringFormat(StringFormatFlags.NoClip); StringFormat format2 = new StringFormat(format1); // Set the LineAlignment and Alignment properties for // both StringFormat objects to different values. format1.set_LineAlignment(StringAlignment.Near); format1.set_Alignment(StringAlignment.Center); format2.set_LineAlignment(StringAlignment.Center); format2.set_Alignment(StringAlignment.Far); // Draw the bounding rectangle and a string for each // StringFormat object. e.get_Graphics().DrawRectangle(Pens.get_Black(), displayRectangle); e.get_Graphics().DrawString("Showing Format1", this.get_Font(), Brushes.get_Red(), (RectangleF.op_Implicit((displayRectangle))), format1); e.get_Graphics().DrawString("Showing Format2", this.get_Font() , Brushes.get_Red(), RectangleF.op_Implicit((displayRectangle)), format2); } //ShowLineAndAlignment

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からStringFormat.Alignment プロパティを検索する場合は、下記のリンクをクリックしてください。

- StringFormat.Alignment プロパティのページへのリンク