syncfusion-winforms-fontlistbox

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Implementing the Syncfusion WinForms FontListBox Control

实现Syncfusion WinForms FontListBox控件

The Syncfusion
FontListBox
(
Syncfusion.Windows.Forms.Tools.FontListBox
) is a
ListBox
-derived control that automatically populates itself with all fonts installed on the user's system. It supports multiple selection modes, type-to-match auto-complete, horizontal scrollbars, item height control, and Office-style visual themes.
Syncfusion
FontListBox
Syncfusion.Windows.Forms.Tools.FontListBox
)是派生自
ListBox
的控件,可自动使用用户系统上安装的所有字体完成自身内容填充。它支持多种选择模式、输入匹配自动补全、水平滚动条、条目高度控制以及Office风格的视觉主题。

When to Use This Skill

何时使用本指南

Use this skill when you need to:
  • Display a list of installed system fonts — auto-populated on creation
  • Allow users to select a font — apply the selected font to labels, text boxes, or other controls
  • Configure selection modes — single, multi-simple, or multi-extended selection
  • Enable type-to-match auto-complete
    UseAutoComplete
  • Apply Office visual styles
    VisualStyle
    with
    FontListBoxStyle
    enum
  • Control scrollbar visibility
    HorizontalScrollbar
    ,
    ScrollAlwaysVisible
  • Handle font selection events
    SelectedIndexChanged
当你需要实现以下需求时可使用本指南:
  • 展示已安装系统字体列表 —— 控件创建时自动填充内容
  • 允许用户选择字体 —— 将选中的字体应用到标签、文本框或其他控件
  • 配置选择模式 —— 单选、简单多选或扩展多选
  • 启用输入匹配自动补全 ——
    UseAutoComplete
  • 应用Office视觉样式 —— 搭配
    FontListBoxStyle
    枚举使用的
    VisualStyle
    属性
  • 控制滚动条可见性 ——
    HorizontalScrollbar
    ScrollAlwaysVisible
  • 处理字体选择事件 ——
    SelectedIndexChanged

Component Overview

组件概览

PropertyTypeDescription
SelectionMode
SelectionMode
One, MultiSimple, or MultiExtended
UseAutoComplete
bool
Type-ahead matching within the list
Sorted
bool
Sort font names alphabetically
ItemHeight
int
Height in pixels of each list item
HorizontalScrollbar
bool
Show horizontal scrollbar when items overflow
HorizontalExtent
int
Width (px) of the scrollable area when horizontal scrollbar is on
ScrollAlwaysVisible
bool
Keep scrollbars visible regardless of item count
VisualStyle
FontListBoxStyle
Office/Metro visual theme
属性类型描述
SelectionMode
SelectionMode
可选值:One、MultiSimple、MultiExtended
UseAutoComplete
bool
列表内的输入预匹配功能
Sorted
bool
按字母顺序排序字体名称
ItemHeight
int
每个列表条目的高度,单位为像素
HorizontalScrollbar
bool
当条目溢出时显示水平滚动条
HorizontalExtent
int
启用水平滚动条时可滚动区域的宽度(像素)
ScrollAlwaysVisible
bool
无论条目数量多少,始终保持滚动条可见
VisualStyle
FontListBoxStyle
Office/Metro视觉主题

Documentation and Navigation Guide

文档与导航指南

Getting Started

入门指南

📄 Read: references/getting-started.md
  • Assembly references and NuGet package setup
  • Adding FontListBox via designer or programmatically
  • Auto-population with system fonts
  • SelectionMode — None, One, MultiSimple, MultiExtended
  • Handling SelectedIndexChanged to apply font to another control
📄 阅读: references/getting-started.md
  • 程序集引用与NuGet包设置
  • 通过设计器或代码方式添加FontListBox
  • 系统字体自动填充
  • SelectionMode可选值:None、One、MultiSimple、MultiExtended
  • 处理SelectedIndexChanged事件将选中字体应用到其他控件

Customization and Behavior

自定义与行为配置

📄 Read: references/customization-and-behavior.md
  • ItemHeight
    — row height per font entry
  • Sorted
    — alphabetical sorting of font names
  • UseAutoComplete
    — type-to-match as user types
  • HorizontalScrollbar
    +
    HorizontalExtent
  • ScrollAlwaysVisible
    — force scrollbars always visible
📄 阅读: references/customization-and-behavior.md
  • ItemHeight
    —— 每个字体条目的行高
  • Sorted
    —— 字体名称按字母排序
  • UseAutoComplete
    —— 用户输入时自动匹配对应条目
  • HorizontalScrollbar
    +
    HorizontalExtent
  • ScrollAlwaysVisible
    —— 强制滚动条始终可见

Visual Styles

视觉样式

📄 Read: references/visual-styles.md
  • VisualStyle
    property using
    FontListBoxStyle
    enum
  • Available styles: Default, Metro, Office2016Colorful, Office2016White, Office2016Black, Office2016DarkGray
📄 阅读: references/visual-styles.md
  • 搭配
    FontListBoxStyle
    枚举使用的
    VisualStyle
    属性
  • 可用样式:Default、Metro、Office2016Colorful、Office2016White、Office2016Black、Office2016DarkGray

Quick Start

快速开始

C#:
csharp
using Syncfusion.Windows.Forms.Tools;

FontListBox fontListBox1 = new FontListBox();
fontListBox1.Size = new System.Drawing.Size(160, 94);
fontListBox1.UseAutoComplete = true;
fontListBox1.SelectionMode = System.Windows.Forms.SelectionMode.One;
fontListBox1.SelectedIndexChanged += FontListBox1_SelectedIndexChanged;
this.Controls.Add(fontListBox1);

private void FontListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    label1.Font = new System.Drawing.Font(
        fontListBox1.SelectedItem.ToString(), 11, System.Drawing.FontStyle.Regular);
}
VB.NET:
vb
Imports Syncfusion.Windows.Forms.Tools

Dim fontListBox1 As New FontListBox()
fontListBox1.Size = New System.Drawing.Size(160, 94)
fontListBox1.UseAutoComplete = True
fontListBox1.SelectionMode = System.Windows.Forms.SelectionMode.One
AddHandler fontListBox1.SelectedIndexChanged, AddressOf FontListBox1_SelectedIndexChanged
Me.Controls.Add(fontListBox1)

Private Sub FontListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
    label1.Font = New System.Drawing.Font(
        fontListBox1.SelectedItem.ToString(), 11, System.Drawing.FontStyle.Regular)
End Sub
C#:
csharp
using Syncfusion.Windows.Forms.Tools;

FontListBox fontListBox1 = new FontListBox();
fontListBox1.Size = new System.Drawing.Size(160, 94);
fontListBox1.UseAutoComplete = true;
fontListBox1.SelectionMode = System.Windows.Forms.SelectionMode.One;
fontListBox1.SelectedIndexChanged += FontListBox1_SelectedIndexChanged;
this.Controls.Add(fontListBox1);

private void FontListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    label1.Font = new System.Drawing.Font(
        fontListBox1.SelectedItem.ToString(), 11, System.Drawing.FontStyle.Regular);
}
VB.NET:
vb
Imports Syncfusion.Windows.Forms.Tools

Dim fontListBox1 As New FontListBox()
fontListBox1.Size = New System.Drawing.Size(160, 94)
fontListBox1.UseAutoComplete = True
fontListBox1.SelectionMode = System.Windows.Forms.SelectionMode.One
AddHandler fontListBox1.SelectedIndexChanged, AddressOf FontListBox1_SelectedIndexChanged
Me.Controls.Add(fontListBox1)

Private Sub FontListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
    label1.Font = New System.Drawing.Font(
        fontListBox1.SelectedItem.ToString(), 11, System.Drawing.FontStyle.Regular)
End Sub

Common Use Cases

常见使用场景

ScenarioProperties to Set
Font picker for a text editor
SelectionMode = One
, handle
SelectedIndexChanged
Multi-font selection
SelectionMode = MultiExtended
Fast keyboard navigation
UseAutoComplete = true
Always show scrollbar
ScrollAlwaysVisible = true
Alphabetically sorted list
Sorted = true
Office-style appearance
VisualStyle = FontListBoxStyle.Office2016Colorful
场景需要设置的属性
文本编辑器的字体选择器
SelectionMode = One
,处理
SelectedIndexChanged
事件
多字体选择
SelectionMode = MultiExtended
快速键盘导航
UseAutoComplete = true
始终显示滚动条
ScrollAlwaysVisible = true
按字母顺序排序列表
Sorted = true
Office风格外观
VisualStyle = FontListBoxStyle.Office2016Colorful