virtual large data reading from log file into a ListView

冷暖自知 提交于 2020-01-03 04:47:06

问题


I've been doing some research on how to read large log files, ~500mbs and parse them into a gui using c#. I'm fairly new using virtual mode for listview...

I've decided on using a listbox with virtual mode (hopefully this can handle about 1mil log messages). but I'm having problem reading the lines of the log file into the listbox.

i don't want to read the whole file, because it would crash the program, so im using File.ReadLines in a foreach statement.

I guess I'm having trouble handling the RetrieveVirtualItem handler to read my file, and get a new row and populate it with

    private void listView1_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
    {
          ListViewItem lvi = new ListViewItem();
        lvi.Text = addList(); // need to read a new row
        ListViewItem.ListViewSubItem lvsi = new ListViewItem.ListViewSubItem();
        lvsi.Text = e.ItemIndex.ToString("n");
        lvi.SubItems.Add(lvsi);
        e.Item = lvi;
    }

how do i read each line of the file and associate it with a virtual retrieval method for listview?

i eventually want to add searching, so it only displays rows in which it hits the matches.

I'm also not sure how to edit the listView1.VirtualListSize - how do i make this a variable that is equal to the amount of matches? i think because it needs a value as i load the form.

来源:https://stackoverflow.com/questions/12788377/virtual-large-data-reading-from-log-file-into-a-listview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!