如何隐藏 listviewitem c# 中的前三列

发布于 2024-12-09 08:52:48 字数 1803 浏览 0 评论 0原文

我是列表视图中的新手。

我使用此代码在列表视图中显示文本文件中的数据,

        int iRecords = 0;
        int iDate = 0;

        using (var sr = File.OpenText("C:\\test.txt"))
        {
            string line;
            bool flag = true;

            while ((line = sr.ReadLine()) != null)
            {
                string[] reader2 = line.Split(',');
                string Date = reader2[0];
                string rate = reader2[1];
                string Sym = reader2[2];
                double price = Convert.ToDouble(reader2[3]);
                double Sell = Convert.ToDouble(reader2[4]);
                double Buy = Convert.ToDouble(reader2[5]);

                ListViewItem lItem = listView1.Items.Insert(iRecords, Date.ToString());
                //lItem.SubItems.Add(Date.ToString());
                lItem.UseItemStyleForSubItems = false;
                lItem.SubItems.Add(rate .ToString());
                lItem.SubItems.Add(Sym .ToString());
                lItem.SubItems.Add(Sell.ToString(), Color.White, Color.Red, lItem.Font);
                lItem.SubItems.Add(Buy .ToString()(), Color.Green, Color.Red, lItem.Font);
                iRecords++;
            }
        }

在此代码中,它显示文本文件中的日期

例如

  • Apple - 5 Min,9532,Buy,20100104,90500,5225,5232,5210 ,5219.7,469950,0
  • 苹果 - 5 Min,9532,Sell,20100104,91000,5221.25,5225.9,5215,5221.7,387650,0

前三个数组是相同的,它们是 * Apple - 5 Min,9532

我想按原样显示第一行, 和销售的第二行,我想隐藏第二行中的前三个数组

,然后为 Mange 隐藏相同的

  • Mango - 5 Min,9532,Buy,20100104,90500,5225
  • Mango - 5 Min,9532,Sell,20100104, 91000,5221.25

我想在列表视图中显示类似的内容

  • Mango - 5分钟,9532,买入,20100104,90500,5225

    <前><代码> 出售,20100104,91000,5221.25

提前致谢。

I am new in list view .

I am using this code to display data from a text file in a list view,

        int iRecords = 0;
        int iDate = 0;

        using (var sr = File.OpenText("C:\\test.txt"))
        {
            string line;
            bool flag = true;

            while ((line = sr.ReadLine()) != null)
            {
                string[] reader2 = line.Split(',');
                string Date = reader2[0];
                string rate = reader2[1];
                string Sym = reader2[2];
                double price = Convert.ToDouble(reader2[3]);
                double Sell = Convert.ToDouble(reader2[4]);
                double Buy = Convert.ToDouble(reader2[5]);

                ListViewItem lItem = listView1.Items.Insert(iRecords, Date.ToString());
                //lItem.SubItems.Add(Date.ToString());
                lItem.UseItemStyleForSubItems = false;
                lItem.SubItems.Add(rate .ToString());
                lItem.SubItems.Add(Sym .ToString());
                lItem.SubItems.Add(Sell.ToString(), Color.White, Color.Red, lItem.Font);
                lItem.SubItems.Add(Buy .ToString()(), Color.Green, Color.Red, lItem.Font);
                iRecords++;
            }
        }

In this code ,it is displaying the date from a text file

For example

  • Apple - 5 Min,9532,Buy,20100104,90500,5225,5232,5210,5219.7,469950,0
  • Apple - 5 Min,9532,Sell,20100104,91000,5221.25,5225.9,5215,5221.7,387650,0

the first three arrays are same , they are * Apple - 5 Min,9532

I want to display the first line as it is ,
and the second line from sell, i want to hide the first three arrays in the second line

and later for Mange the same

  • Mango - 5 Min,9532,Buy,20100104,90500,5225
  • Mango - 5 Min,9532,Sell,20100104,91000,5221.25

I wanto to display something like this in a listview

  • Mango - 5 Min,9532,Buy,20100104,90500,5225

                 Sell,20100104,91000,5221.25
    

Thanks In Advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

木槿暧夏七纪年 2024-12-16 08:52:48

试试这个..

将要隐藏的列的宽度设置为 0。

示例:
lstVItem.Columns[0].Width = 0;

Try This..

Set the width of the column/s you want to hide to 0.

Example:
lstVItem.Columns[0].Width = 0;

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文