Size.Round(SizeF) メソッド

定義

指定の SizeF 構造体を、Size 構造体の値を最も近い整数値に丸めることによって、SizeF 構造体に変換します。

public:
 static System::Drawing::Size Round(System::Drawing::SizeF value);
public static System.Drawing.Size Round (System.Drawing.SizeF value);
static member Round : System.Drawing.SizeF -> System.Drawing.Size
Public Shared Function Round (value As SizeF) As Size

パラメーター

value
SizeF

変換対象の SizeF 構造体。

戻り値

このメソッドの変換対象の Size 構造体。

次のコード例では、静的 Round メソッドと Truncate メソッドを使用して を に変換 SizeF する方法を Size示します。 この例は、Windows フォームで使用するように設計されています。 この例を実行するには、 と Label2という名前Label1の 2 つのLabelオブジェクトを含むフォームに貼り付け、フォームのコンストラクターからこのメソッドを呼び出します。

void TruncateAndRoundSizes()
{
   // Create a SizeF.
   SizeF theSize = SizeF(75.9F,75.9F);
   
   // Round the Size.
   System::Drawing::Size roundedSize = ::Size::Round( theSize );
   
   // Truncate the Size.
   System::Drawing::Size truncatedSize = ::Size::Truncate( theSize );
   
   //Print out the values on two labels.
   Label1->Text = String::Format( "Rounded size = {0}", roundedSize );
   Label2->Text = String::Format( "Truncated size = {0}", truncatedSize );
}
private void TruncateAndRoundSizes()
{

    // Create a SizeF.
    SizeF theSize = new SizeF(75.9F, 75.9F);

    // Round the Size.
    Size roundedSize = Size.Round(theSize);

    // Truncate the Size.
    Size truncatedSize = Size.Truncate(theSize);

    //Print out the values on two labels.
    Label1.Text = "Rounded size = "+roundedSize.ToString();
    Label2.Text = "Truncated size = "+truncatedSize.ToString();
}
Private Sub TruncateAndRoundSizes()

    ' Create a SizeF.
    Dim theSize As New SizeF(75.9, 75.9)

    ' Round the Size.
    Dim roundedSize As Size = Size.Round(theSize)

    ' Truncate the Size.
    Dim truncatedSize As Size = Size.Truncate(theSize)

    'Print out the values on two labels.
    Label1.Text = "Rounded size = " & roundedSize.ToString()
    Label2.Text = "Truncated size = " & truncatedSize.ToString

End Sub

適用対象