Size.Round(SizeF) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
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
參數
傳回
這個方法轉換成的 Size。
範例
下列程式代碼範例示範如何使用靜態 Round 和方法,將轉換成 SizeFSize。Truncate 此範例的設計目的是要與 Windows Forms 搭配使用。 若要執行此範例,請將它貼到包含兩 Label 個名為 Label1
和 Label2
的物件表單中,然後從表單的建構函式呼叫這個方法。
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