virtual large data reading from log file into a Li

2019-06-14 11:41发布

问题:

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.