符号字体作为DataGridView中的图标

时间:2015-07-21 15:20:21

标签: c# image datagridview fonts symbols

我知道在DataGridview中,我们可以将ImageColumn绑定到图像数据以显示图标,例如。通常我会使用Microsoft的MsoImage中的图标。

enter image description here

在我看来,从符号字体,我们可以有很多漂亮的图标。是否可以将列绑定到文本,并考虑字体,以便我们可以使用符号字体并显示看起来像图标的文本+字体的结果。

enter image description here

如果无法进行文本绑定,是否有其他方法可以将符号字体提取/转换为图像?

1 个答案:

答案 0 :(得分:2)

您只需为列设置字体即可。这是一个例子:

enter image description here

List<daz> dazz = new List<daz>() { new daz("♻", "267B"), new daz("⚔", "2694") };
Font f = new Font("Segue UI Symbol", 12f);
dataGridView1.DataSource = dazz;
dataGridView1.Columns[0].DefaultCellStyle.Font = f;

忽略示例类:

class daz
{
    public string code { get; set; }
    public string text { get; set; }
    public daz (string c, string t) { code = c;  text = t; }
}
相关问题