Control.Region プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

コントロールに関連付けられたウィンドウ Region。

ウィンドウ領域は、オペレーティング システムで描画が許可されているウィンドウ内のピクセルのコレクションです。オペレーティング システムは、ウィンドウ領域の外側にある部分は表示しません。コントロールの領域の座標は、コントロールのクライアント領域に対する相対座標ではなく、コントロールの左上隅に対する相対座標です。
![]() |
---|

丸ボタンを作成し、Regionプロパティを使用する方法を次のコード例に示します。この例を実行するには、roundButton という名前のボタンが配置されているフォームに、次のコードを貼り付けます。この例では、Paint イベントが、この例で定義されているイベント ハンドラに関連付けられている必要があります。
' This method will change the square button to a circular button by ' creating a new circle-shaped GraphicsPath object and setting it ' to the RoundButton objects region. Private Sub roundButton_Paint(ByVal sender As Object, _ ByVal e As System.Windows.Forms.PaintEventArgs) Handles roundButton.Paint Dim buttonPath As New System.Drawing.Drawing2D.GraphicsPath ' Set a new rectangle to the same size as the button's ' ClientRectangle property. Dim newRectangle As Rectangle = roundButton.ClientRectangle ' Decrease the size of the rectangle. newRectangle.Inflate(-10, -10) ' Draw the button's border. 'e.Graphics.DrawEllipse(System.Drawing.Pens.Black, newRectangle) 'Increase the size of the rectangle to include the border. newRectangle.Inflate(1, 1) ' Create a circle within the new rectangle. buttonPath.AddEllipse(newRectangle) e.Graphics.DrawPath(Pens.Black, buttonPath) ' Set the button's Region property to the newly created ' circle region. roundButton.Region = New System.Drawing.Region(buttonPath) End Sub
// This method will change the square button to a circular button by // creating a new circle-shaped GraphicsPath object and setting it // to the RoundButton objects region. private void roundButton_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { System.Drawing.Drawing2D.GraphicsPath buttonPath = new System.Drawing.Drawing2D.GraphicsPath(); // Set a new rectangle to the same size as the button's // ClientRectangle property. System.Drawing.Rectangle newRectangle = roundButton.ClientRectangle; // Decrease the size of the rectangle. newRectangle.Inflate(-10, -10); // Draw the button's border. e.Graphics.DrawEllipse(System.Drawing.Pens.Black, newRectangle); // Increase the size of the rectangle to include the border. newRectangle.Inflate( 1, 1); // Create a circle within the new rectangle. buttonPath.AddEllipse(newRectangle); // Set the button's Region property to the newly created // circle region. roundButton.Region = new System.Drawing.Region(buttonPath); }
private: // This method will change the square button to a circular button by // creating a new circle-shaped GraphicsPath object and setting it // to the RoundButton objects region. void roundButton_Paint( Object^ sender, System::Windows::Forms::PaintEventArgs^ e ) { System::Drawing::Drawing2D::GraphicsPath^ buttonPath = gcnew System::Drawing::Drawing2D::GraphicsPath; // Set a new rectangle to the same size as the button's // ClientRectangle property. System::Drawing::Rectangle newRectangle = roundButton->ClientRectangle; // Decrease the size of the rectangle. newRectangle.Inflate( -10, -10 ); // Draw the button's border. e->Graphics->DrawEllipse( System::Drawing::Pens::Black, newRectangle ); // Increase the size of the rectangle to include the border. newRectangle.Inflate( 1, 1 ); // Create a circle within the new rectangle. buttonPath->AddEllipse( newRectangle ); // Set the button's Region property to the newly created // circle region. roundButton->Region = gcnew System::Drawing::Region( buttonPath ); }
// This method will change the square button to a circular button by // creating a new circle-shaped GraphicsPath object and setting it // to the RoundButton objects region. private void roundButton_Paint(Object sender, System.Windows.Forms.PaintEventArgs e) { System.Drawing.Drawing2D.GraphicsPath buttonPath = new System.Drawing.Drawing2D.GraphicsPath(); // Set a new rectangle to the same size as the button's // ClientRectangle property. System.Drawing.Rectangle newRectangle = roundButton.get_ClientRectangle(); // Decrease the size of the rectangle. newRectangle.Inflate(-10, -10); // Draw the button's border. e.get_Graphics().DrawEllipse(System.Drawing.Pens.get_Black(), newRectangle); // Increase the size of the rectangle to include the border. newRectangle.Inflate(1, 1); // Create a circle within the new rectangle. buttonPath.AddEllipse(newRectangle); // Set the button's Region property to the newly created // circle region. roundButton.set_Region(new System.Drawing.Region(buttonPath)); } //roundButton_Paint


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に収録されているすべての辞書からControl.Region プロパティを検索する場合は、下記のリンクをクリックしてください。

- Control.Region プロパティのページへのリンク