Note that there are some explanatory texts on larger screens.

plurals
  1. POloading textfile in to two dimensional array C# GUI
    primarykey
    data
    text
    <p>So most things ive read about loading textfiles in windows form shows you loading it into a single dimension string array. but I have some features id like to do that would work much better if it were a two dimensional array. in this example i have a book catalog with isbn, author, title, year, price. I want to be able to compile data about most expensive and least expensive book (which I'm able to do already from the array that i have for user entry), and be able to search the array by title, isbn, etc. I also am displaying it in a multicolumn listview. </p> <p>Heres what I have for loading the textfile (which is new records separated by new lines, and it is tab ('\t') delimited) and displaying it in the multicolumn listview. What would I need to do to load this into a 2D array? and how would i display it? any help would be great.</p> <pre><code>static FileStream textFile = new FileStream("booklist.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite); StreamReader reader = new StreamReader(textFile); StreamWriter writer = new StreamWriter(textFile); const char DELIM = '\t'; //string[] booksTextArray; string line = ""; string[] items; ListViewItem listItem; // the load button private void LoadButton_Click(object sender, EventArgs e) { // loads text file with existing book catalog while((line = reader.ReadLine()) != null) { items = line.Split('\t'); //Split the line. listItem = new ListViewItem(); //"Row" object. for (int i = 0; i &lt; items.Length; i++) { if (i == 0) { listItem.Text = items[i]; //First item is not a "subitem". } else { listItem.SubItems.Add(items[i]); //Add it to the "Row" object. } } listView1.Items.Add(listItem); //Add the row object to the listview. status_label.Text = "Load successful."; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload