3
我有一个列表视图,我想根据某些条件在不同的单元格中应用不同的字体。但我无法做到这一点。我试过这些类型的代码来添加项目。ListView子项字体不工作
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);
和
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);
当我使用零子项,更改字体,新的字体应用到整行。但我只想要particluarl单元格应用字体。
Winforms仅支持TrueType字体。这篇文章建议kf-kiran不是:http://stackoverflow.com/questions/5547570/which-marathiindia-font-maps-exactly-with-the-qwerty-keyboard –
感谢您的回复,但尽管我使用基本字体如“arial”,则不应用字体更改。 – user952125
嗨得到了解决方案。我使用的软件主题,我排除了从主题的列表视图,并开始工作 – user952125