⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 formbindinglist.cs

📁 csharp课本的源代码
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ShowFontExample
{
    public partial class FormBindingList : Form
    {
        public FormBindingList()
        {
            InitializeComponent();
        }
        private void bindingSource1_CurrentChanged(object sender, EventArgs e)
        {
            label1.Font = (Font)bindingSource1.Current;
        }
         private void FormBindingList_Load(object sender, EventArgs e)
        {
            //创建一个类型为Font的List泛型数组
            List<Font> fonts = new List<Font>();
            //读取所有支持的字体
            for (int i = 0; i < FontFamily.Families.Length; i++)
            {
                if (FontFamily.Families[i].IsStyleAvailable(FontStyle.Regular))
                {
                    fonts.Add(new Font(FontFamily.Families[i], 20.0F, FontStyle.Regular));
                }
            }
            bindingSource1.DataSource = fonts;
            listBox1.DataSource = bindingSource1;
            //在列表项中绑定字体名称
            listBox1.DisplayMember = "Name";
            //将字体名称绑定到label1的Text属性
            label1.DataBindings.Add("Text", bindingSource1, "Name");
            bindingNavigator1.BindingSource = bindingSource1;
        }

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -