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.
ListViewItem.UseItemStyleForSubItems = false;
This denies first subitem's font style to be applied automatically on all subitems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With