当前位置: 首页>>代码示例>>C#>>正文


C# Font.Size属性代码示例

本文整理汇总了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;
    }
}
开发者ID:.NET开发者,项目名称:System.Drawing,代码行数:41,代码来源:Font.Size

示例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());
  }

}
开发者ID:C#程序员,项目名称:System.Drawing,代码行数:36,代码来源:Font.Size


注:本文中的System.Drawing.Font.Size属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。