FontFamily.Families 属性

定义

返回一个数组,该数组包含与当前图形上下文相关的所有 FontFamily 对象。

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

属性值

与当前图形上下文相关的 FontFamily 对象的数组。

示例

下面的代码示例显示了 类的 属性FontFamily中的所有Families字体系列。 此示例旨在与 Windows 窗体一起使用。 若要运行此示例,请将名为 listBox1 的 添加到ListBox窗体,并从窗体的构造函数调用 PopulateListBoxWithFonts 方法。

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

适用于