本文整理匯總了C#中System.Drawing.Font.Size屬性的典型用法代碼示例。如果您正苦於以下問題:C# Font.Size屬性的具體用法?C# Font.Size怎麽用?C# Font.Size使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Drawing.Font
的用法示例。
在下文中一共展示了Font.Size屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ComboBox1_SelectedIndexChanged
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;
}
}
示例2: FontConstructor3
//引入命名空間
using System;
using System.Drawing;
using System.Windows.Forms;
public class FontConstructor3 : Form
{
public FontConstructor3()
{
Text = "Font Constructor";
Size = new Size(350,200);
FontFamily ff = new FontFamily("Times New Roman");
Font fnt = new Font(ff, 12, FontStyle.Bold | FontStyle.Italic);
Font = fnt;
RichTextBox rtxt = new RichTextBox();
rtxt.Text = "first line.\n" +
"This is a second line of text.";
rtxt.Text += "\nFont Name:\t" + Font.Name;
rtxt.Text += "\nFont Family:\t" + Font.FontFamily;
rtxt.Text += "\nFont Styles:\t" + Font.Style;
rtxt.Text += "\nFont Size:\t" + Font.Size;
rtxt.Text += "\nFont Height:\t" + Font.Height;
rtxt.Text += "\nFont Units:\t" + Font.Unit;
rtxt.Multiline = true;
rtxt.Dock = DockStyle.Fill;
rtxt.Parent = this;
}
static void Main()
{
Application.Run(new FontConstructor3());
}
}