FontFamily.Families 属性

定义

返回一个数组,该数组包含与当前图形上下文相关的所有 FontFamily 对象。Returns an array that contains all the FontFamily objects associated with the current graphics context.

public:
 static property cli::array <System::Drawing::FontFamily ^> ^ Families { cli::array <System::Drawing::FontFamily ^> ^ get(); };
public static System.Drawing.FontFamily[] Families { get; }
member this.Families : System.Drawing.FontFamily[]
Public Shared ReadOnly Property Families As FontFamily()

属性值

FontFamily[]

与当前图形上下文相关的 FontFamily 对象的数组。An array of FontFamily objects associated with the current graphics context.

示例

下面的代码示例演示了类的属性中的所有字体系列 Families FontFamilyThe following code example shows all the font families in the Families property of the FontFamily class. 此示例旨在与 Windows 窗体一起使用。This example is designed to be used with a Windows Form. 若要运行此示例,请向 ListBox 窗体添加一个名为的, listBox1PopulateListBoxWithFonts 从窗体的构造函数中调用方法。To run this example, add a ListBox named listBox1 to a form and call the PopulateListBoxWithFonts method from the form's constructor.

private:
   void PopulateListBoxWithFonts()
   {
      listBox1->Width = 200;
      listBox1->Location = Point(40,120);
      System::Collections::IEnumerator^ myEnum = FontFamily::Families->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         FontFamily^ oneFontFamily = safe_cast<FontFamily^>(myEnum->Current);
         listBox1->Items->Add( oneFontFamily->Name );
      }
   }
private void PopulateListBoxWithFonts()
{
    listBox1.Width = 200;
    listBox1.Location = new Point(40, 120);
    foreach ( FontFamily oneFontFamily in FontFamily.Families )
    {
        listBox1.Items.Add(oneFontFamily.Name);
    }
}
Private Sub PopulateListBoxWithFonts()
    listBox1.Width = 200
    listBox1.Location = New Point(40, 120)
    Dim oneFontFamily As FontFamily
    For Each oneFontFamily In FontFamily.Families
        listBox1.Items.Add(oneFontFamily.Name)
    Next
End Sub

适用于