Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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.

like image 214
user952125 Avatar asked Oct 01 '11 12:10

user952125


1 Answers

ListViewItem.UseItemStyleForSubItems = false;

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

like image 80
Someone Avatar answered Nov 06 '22 23:11

Someone