Export (0) Print
Expand All

Font.SizeInPoints Property

Gets the em-size, in points, of this Font.

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

[BrowsableAttribute(false)]
public float SizeInPoints { get; }

Property Value

Type: System.Single
The em-size, in points, of this Font.

The following code example demonstrates how to use the Font constructor and the Size, SizeInPoints, and Unit properties. This example is designed to be used with a Windows Form that contains a ComboBox named ComboBox1 that is populated with the strings "Bigger" and "Smaller". Paste the following code into the form and associate the ComboBox1_SelectedIndexChanged method with the SelectedIndexChanged event of the ComboBox control.

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

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft