Size.Truncate(SizeF) Méthode

Définition

Convertit la structure SizeF spécifiée en structure Size en tronquant les valeurs de la structure SizeF aux valeurs entières inférieures suivantes.

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

Paramètres

value
SizeF

Structure SizeF à convertir.

Retours

Structure Size dans laquelle cette méthode effectue une conversion.

Exemples

L’exemple de code suivant montre comment utiliser des méthodes statiques Round et Truncate pour convertir un SizeF en .Size Cet exemple est conçu pour être utilisé avec Windows Forms. Pour exécuter cet exemple, collez-le dans un formulaire qui contient deux Label objets nommés Label1 et Label2, puis appelez cette méthode à partir du constructeur du formulaire.

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

S’applique à