ListView的子项目字体不工作 [英] ListView subitems font not working

查看:100
本文介绍了ListView的子项目字体不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,我想根据一些条件采用不同的字体在不同的细胞中的列表视图。但我无法做到这一点。我想这些类型的codeS添加的项。

  ListViewItem的entryListItem = listView_Standard.Items.Add(项目);

            //设置UseItemStyleForSubItems属性设置为false改变
            //看子项目。
            entryListItem.UseItemStyleForSubItems = FALSE;

            //添加支出子项目。
            ListViewItem.ListViewSubItem的ExpenseItem =
                entryListItem.SubItems.Add(费用);

            //改变的ExpenseItem对象的颜色和字体。
            expenseItem.ForeColor = System.Drawing.Color.Red;
            expenseItem.Font =新System.Drawing.Font(
                Arial字体,10,System.Drawing.FontStyle.Italic);

            //添加一个名为revenueItem子项
            ListViewItem.ListViewSubItem revenueItem =
                entryListItem.SubItems.Add(收入);
            revenueItem.BackColor = System.Drawing.Color.Red;

            //改变revenueItem对象的颜色和字体。
            revenueItem.ForeColor = System.Drawing.Color.Blue;
            revenueItem.Font =新System.Drawing.Font(
                KF-基兰,25,System.Drawing.FontStyle.Bold);
 

 的ListViewItem的newitem =新的ListViewItem();
             NewItem.UseItemStyleForSubItems = FALSE;
             NewItem.Text =富;
             NewItem.SubItems.Add(巴);
             NewItem.SubItems.Add(1111111);
             NewItem.SubItems [1] .Font =新字体(KF-吉兰,20);
listView_Standard.Items.Add(的newitem);
 

当我使用0号子项,更改字体,新的字体被应用到整行。但我想只有particluarl细胞应用字体。

解决方案

  ListViewItem.UseItemStyleForSubItems = FALSE;
 

这否认第一子项目的字体样式将自动对所有子项应用。

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.

这篇关于ListView的子项目字体不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆