Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FORM 1 -------------------------------------------------------------------------------------------------------
- public partial class Form1 : Form
- {
- private List<Song> l = new List<Song>();
- public Form1()
- {
- InitializeComponent();
- LoadSongs();
- LoadTable();
- }
- public void LoadSongs()
- {
- FileStream fs = new FileStream(@"C:\Users\Mikey\Desktop\?.txt", FileMode.Open);
- StreamReader r= new StreamReader(fs);
- while (!r.EndOfStream)
- {
- string line = r.ReadLine();
- string[] arr = line.Split('|');
- Song x = new Song( arr[0], arr[1], arr[2], double.Parse(arr[3]) );
- l.Add(x);
- }
- r.Close();
- fs.Close();
- }
- public void LoadTable()
- {
- foreach (Song s in l)
- {
- dataGridView1.Rows.Add(s.artist, s.album, s.genre, s.price);
- }
- }
- private void dataGridView1_CellClick_1(object sender, DataGridViewCellEventArgs e)
- {
- //MessageBox.Show("You have selected row number" + dataGridView1.SelectedRows[0].Cells[0].Value + "");
- //MessageBox.Show("You have selected row number " + dataGridView1.SelectedRows[0].Index);
- }
- }
- SONG -------------------------------------------------------------------------------------------------------
- class Song
- {
- public string artist, album, genre;
- public double price;
- public Song(string a, string alb, string g, double p)
- {
- artist = a;
- album = alb;
- genre = g;
- price = p;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement