Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

ListView add SubItems from a text file problem

$
0
0

Hello,

I trying to add SubItems from a text file in a listbox.

I have a bug right now,

Example if i have 1 2 3 4 5 in my text file it will display it but it will aslo multiply every items by 5.

How can i make my code adding only the data from my file to the SubItems?

I am using VC++ WINFORMS

Code:

		Form1(void)
		{
			InitializeComponent();

			//
			//TODO: Add the constructor code here
			//


             ifstream ss_dfs_output("test.txt");
             string TempStoreToDisp;
             vector<string> VecToDisp;
             vector<string>::iterator ToDisp_ptr;
             string OutToDisp;
             while (getline(ss_dfs_output,TempStoreToDisp,'\n'))
             {
                 VecToDisp.push_back(TempStoreToDisp);
             }
             for (ToDisp_ptr=VecToDisp.begin();ToDisp_ptr!=VecToDisp.end();ToDisp_ptr++)
             {
                 OutToDisp = *ToDisp_ptr;
                 String ^sss = Convert::ToString(OutToDisp.c_str());


   array<String^>^foodList = {"Juice","Coffee","Cereal & Milk","Fruit Plate","Toast & Jelly","Bagel & Cream Cheese"};
   for ( int count = 0; count < foodList->Length; count++ )
   {
      ListViewItem^ listItem = gcnew ListViewItem( foodList[ count ] );
      listItem->SubItems->Add( gcnew String(OutToDisp.c_str()) );
      listView1->Items->Add( listItem );

   }
				           
			 
		}	 
		}

Screen:




Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>