列表视图中指定列的粗体文本不起作用

Bold text for specified column from listview not working

这段代码有什么问题?第 3 个索引列文本未加粗。

foreach (ListViewItem itm in listView1.Items)
{
    itm.SubItems[3].Font = new Font(listView1.Font, FontStyle.Bold);
}

这会起作用:

// create temp font from the item, using BOLD
using (Font f = new Font(lv1.Items(0).SubItems(0).Font, FontStyle.Bold))
{
    // loop thru all items
    foreach (ListViewItem itm in listView1.Items)
    {
        // tell SubItems not to use Item Style & set the font
        itm.UseItemStyleForSubItems = False;
        itm.SubItems[3].Font = f;
    }
}  // dispose of font

除非你另有说明,否则默认是SubItems使用与父Item相同的字体和颜色。这是一个项目级别 属性,因此必须为 每个 项目设置它,您希望其中的任何子项目有所不同。