c# - Divide text file to display each of its line on different forms -


i'm trying divide uploaded textfile data displayed on different textboxes/listboxes. each line of textfile divided. example:

lets textfile have content(one value per line):

kevin

simon

john

later want display each line of textfile on different forms, example:

textbox1 displays line 1(which kevin)

textbox2 displays line 2(which simon)

listbox1 displays line 3 (which john)

i'm wondering if possible , if give example.

thank you.

update:

how add couple of textfile lines listbox? tried doesnt add listview

 public void openfile()         {             openfiledialog openfiledialog = new openfiledialog();             openfiledialog.filter = "text files (*.txt)|*.txt|all files (*.*)|*.*";             string line = "";             int index = 0;             if (openfiledialog.showdialog() == true)             using (streamreader sr = file.opentext(openfiledialog.filename))             {                 while ((line = sr.readline()) != null)                 {                     index++;                     if (index == 1)                         invoicenumbertxt.text = line;                     else if (index == 2)                         invoicedatetxt.text = line;                     else if (index == 3)                         duedatetxt.text = line;                     else if (index == 3 && index == 4 && index == 5 && index == 6 && index == 7 && index == 8)                         personinfolst.items.add(line);                     else                         break;                 }             }         } 

fixed it

you try simple like:

string line = ""; int index = 0; using (streamreader sr = file.opentext("pathtofile")) {     while ((line = sr.readline()) != null)     {         index++;         if(index == 1)             textbox1.text = line;         else if(index == 2)             textbox2.text = line;         else if(index == 3)             listbox1.items.add(line);         else             break;     } } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -