Font.Size プロパティ
アセンブリ: System.Drawing (system.drawing.dll 内)


Font コンストラクタと Size、SizeInPoints、および Unit の各プロパティを使用する方法を次のコード例に示します。この例は、ComboBox1 という名前の ComboBox に "Bigger" と "Smaller" という文字列が設定された Windows フォームでの使用を意図してデザインされています。そして、次のコードをそのフォームに貼り付け、ComboBox1_SelectedIndexChanged メソッドに、ComboBox コントロールの SelectedIndexChanged イベントを関連付けます。
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged ' Cast the sender object back to a ComboBox. Dim ComboBox1 As ComboBox = CType(sender, ComboBox) ' Retrieve the selected item. Dim selectedString As String = CType(ComboBox1.SelectedItem, String) ' Convert it to lowercase. selectedString = selectedString.ToLower() ' Declare the current size. Dim currentSize As Single ' Switch on the selected item. Select Case 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. Case "smaller" currentSize = Label1.Font.SizeInPoints currentSize -= 1 Label1.Font = New Font(Label1.Font.Name, currentSize, _ Label1.Font.Style) End Select End Sub
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; } }
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; // 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. if (selectedString == "bigger") { currentSize = Label1->Font->Size; currentSize += 2.0F; Label1->Font =gcnew System::Drawing::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 2. Reset the font with // the new size in points. if (selectedString == "smaller") { currentSize = Label1->Font->Size; currentSize -= 2.0F; Label1->Font = gcnew System::Drawing::Font(Label1->Font->Name, currentSize, Label1->Font->Style); } }
private void comboBox1_SelectedIndexChanged(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.get_SelectedItem(); // Convert it to lowercase. selectedString = selectedString.ToLower(); // Declare the current size. float currentSize; // Switch on the selected item. // 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. if (selectedString.Equals("bigger")) { currentSize = label1.get_Font().get_Size(); currentSize += 2; label1.set_Font(new Font(label1.get_Font().get_Name(), currentSize, label1.get_Font().get_Style(), label1.get_Font().get_Unit())); } else { // If Smaller is selected, get the current size, in points, // and decrease it by 1. Reset the font with the new size // in points. if (selectedString.Equals("smaller")) { currentSize = label1.get_Font().get_SizeInPoints(); currentSize -= 1; label1.set_Font(new Font(label1.get_Font().get_Name(), currentSize, label1.get_Font().get_Style())); } } } //comboBox1_SelectedIndexChanged

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


FontSize 列挙体
アセンブリ: System.Web.Mobile (system.web.mobile.dll 内)

Public Enumeration FontSize

メンバ名 | 説明 | |
---|---|---|
Large | Normal より大きいフォント サイズです。 | |
Normal | 既定のフォント サイズです。 | |
NotSet | 既定値。値が NotSet の場合は、コントロールのスタイルからフォント サイズが継承されます。そのコントロールでスタイルが定義されていなければ、そのコントロールの親コントロールから継承されます。 | |
Small | Normal より小さいフォント サイズです。 |

FontSize 列挙定数は System.Web.UI.WebControls.FontSize のサブセットで、コンテナ内のフォントのサイズを表します。たとえば、Panel コントロールの内側に List コントロールを配置し、Panel コントロールのフォント サイズを Normal に設定した場合、List コントロールに対して小さいフォント サイズを指定できます。

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


FontSize 列挙体
アセンブリ: System.Web (system.web.dll 内)

Public Enumeration FontSize

メンバ名 | 説明 | |
---|---|---|
AsUnit | フォント サイズはポイント値で指定します。 | |
Large | 基本フォント サイズより 2 サイズ大きいフォント サイズです。 | |
Larger | 親要素のフォント サイズより 1 サイズ大きいフォント サイズです。 | |
Medium | 既定のフォント サイズより 1 サイズ大きいフォント サイズです。 | |
NotSet | フォント サイズが設定されていません。 | |
Small | ブラウザによって決定される基本フォント サイズ。 | |
Smaller | 親要素のフォント サイズより 1 サイズ小さいフォント サイズです。 | |
XLarge | 基本フォント サイズより 3 サイズ大きいフォント サイズです。 | |
XSmall | 基本フォント サイズより 1 サイズ小さいフォント サイズです。 | |
XXLarge | 基本フォント サイズより 4 サイズ大きいフォント サイズです。 | |
XXSmall | 基本フォント サイズより 2 サイズ小さいフォント サイズです。 |

FontSize 列挙体は、HTML 4.0 が定義するフォント サイズを表します。フォント サイズには絶対サイズと相対サイズがあります。
絶対フォント サイズは、ブラウザによって決定される定義済みのフォント サイズです。絶対フォント サイズに指定できる値は、XXSmall、XSmall、Small、Medium、Large、XLarge、および XXLarge です。
相対フォント サイズは、親要素のフォント サイズより 1 サイズ大きい、または 1 サイズ小さいフォント サイズです。相対フォント サイズに指定できる値は、Smaller と Larger です。
![]() |
---|
一部のブラウザでは、Smaller フォント サイズと Larger フォント サイズが認識されません。互換性があるかどうかをブラウザで確認してください。 |

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- font-sizeのページへのリンク