在顶部显示最新列表

时间:2018-05-21 03:09:15

标签: c# winforms listview

我有上传.csv文件的场景,并使用listview显示消息/状态。

以下是代码片段:

listView1.View = View.List;
listView1.Items.Add(new ListViewItem (new[]{"CUID:" + strCuID + " is refunded successfully"}));
listView1.GridLines = true;

输出:

  

01293821921DE成功退款//第一次   0123821921DE成功退还
  01693821921DE已成功退款//最新

我希望最新的结果首先出现。我怎样才能得到预期的结果?

1 个答案:

答案 0 :(得分:0)

OP:我希望最新的结果首先出现。我怎样才能得到预期的结果?

public static void Main()
{
    List<string> ListTest = new List<string>();
    ListTest.Add("01293821921DE is refunded successfully");
    ListTest.Add("0123821921DE is refunded successfully");
    ListTest.Add("01693821921DE is refunded successfully");

    Console.WriteLine("\n List in Order \n");

    foreach(var item in ListTest)
    {
        Console.WriteLine(item);
    }

    Console.WriteLine("\n List in Reverse Order \n");

    for(int i = ListTest.Count() - 1; i >= 0; i--)
    {
        Console.WriteLine(ListTest[i]);
    }
}

输出:

enter image description here

样本:

dotNetFiddle