Este artículo se tradujo de forma manual. Mueva el puntero sobre las frases del artículo para ver el texto original.
Traducción
Original
Este tema aún no ha recibido ninguna valoración - Valorar este tema

Font.Size (Propiedad)

Obtiene el tamaño Em de este objeto Font expresado en las unidades especificadas por la propiedad Unit.

Espacio de nombres:  System.Drawing
Ensamblado:  System.Drawing (en System.Drawing.dll)
public float Size { get; }

Valor de propiedad

Tipo: System.Single
Tamaño Em de esta Font.

En el siguiente ejemplo de código se muestra cómo usar el constructor Font y las propiedades Size, SizeInPoints y Unit. Este ejemplo se ha diseñado para utilizarlo con un formulario Windows Forms que contiene un ComboBox denominado ComboBox1 que se rellena con las cadenas "Bigger" y "Smaller". Pegue el código siguiente en el formulario y asocie el método ComboBox1_SelectedIndexChanged al evento SelectedIndexChanged del control ComboBox.


private void ComboBox1_SelectedIndexChanged(System.Object sender, 
    System.EventArgs e)
{

    // Cast the sender object back to a ComboBox.
    ComboBox ComboBox1 = (ComboBox) sender;

    // Retrieve the selected item.
    string selectedString = (string) ComboBox1.SelectedItem;

    // Convert it to lowercase.
    selectedString = selectedString.ToLower();

    // Declare the current size.
    float currentSize;

    // Switch on the selected item. 
    switch(selectedString)
    {

            // If Bigger is selected, get the current size from the 
            // Size property and increase it. Reset the font to the
            //  new size, using the current unit.
        case "bigger":
            currentSize = Label1.Font.Size;
            currentSize += 2.0F;
            Label1.Font = new Font(Label1.Font.Name, currentSize, 
                Label1.Font.Style, Label1.Font.Unit);

            // If Smaller is selected, get the current size, in points,
            // and decrease it by 1.  Reset the font with the new size
            // in points.
            break;
        case "smaller":
            currentSize = Label1.Font.SizeInPoints;
            currentSize -= 1;
            Label1.Font = new Font(Label1.Font.Name, currentSize, 
                Label1.Font.Style);
            break;
    }
}


.NET Framework

Compatible con: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Compatible con: 4, 3.5 SP1

Windows 7, Windows Vista SP1 o posterior, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (no se admite Server Core), Windows Server 2008 R2 (se admite Server Core con SP1 o posterior), Windows Server 2003 SP2

.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.
¿Te ha resultado útil?
(Caracteres restantes: 1500)

Adiciones de comunidad

AGREGAR
© 2013 Microsoft. Reservados todos los derechos.