开发者

ListView subitems font not working

I have a listview in which I want to apply different font in different cells according to some condition. But I'm unable to do this. I tried these types of开发者_如何学C codes to add item.

ListViewItem entryListItem = listView_Standard.Items.Add("Items");

            // Set UseItemStyleForSubItems property to false to change 
            // look of subitems.
            entryListItem.UseItemStyleForSubItems = false;

            // Add the expense subitem.
            ListViewItem.ListViewSubItem expenseItem =
                entryListItem.SubItems.Add("Expense");

            // Change the expenseItem object's color and font.
            expenseItem.ForeColor = System.Drawing.Color.Red;
            expenseItem.Font = new System.Drawing.Font(
                "Arial", 10, System.Drawing.FontStyle.Italic);

            // Add a subitem called revenueItem 
            ListViewItem.ListViewSubItem revenueItem =
                entryListItem.SubItems.Add("Revenue");
            revenueItem.BackColor = System.Drawing.Color.Red;

            // Change the revenueItem object's color and font.
            revenueItem.ForeColor = System.Drawing.Color.Blue;
            revenueItem.Font = new System.Drawing.Font(
                "KF-Kiran", 25, System.Drawing.FontStyle.Bold);

and

ListViewItem NewItem = new ListViewItem();
             NewItem.UseItemStyleForSubItems = false;
             NewItem.Text = "foo";
             NewItem.SubItems.Add("bar");
             NewItem.SubItems.Add("1111111");
             NewItem.SubItems[1].Font = new Font("KF-Kiran", 20);
listView_Standard.Items.Add(NewItem);

When I use 0th subitem to change font, new font is applied to whole row. But I want only particluarl cells to apply font.


ListViewItem.UseItemStyleForSubItems = false;

This denies first subitem's font style to be applied automatically on all subitems.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜