Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Diagnostics;
- namespace laibery
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- // the list that we need to transfer to form2
- // lOcI = list Of card Index, from now i'll call her "our list"
- public List<CardIndex> lOcI = new List<CardIndex>();
- private void saveDtls_Click(object sender, EventArgs e)
- {
- lOcI.Add(new CardIndex(book.Text, writer.Text, price.Text, quantity.Text));
- book.Text = writer.Text = price.Text = quantity.Text = "";
- }
- //all the constructer & method that transfer our list to form2
- //#1 constructer that get a list and adds to her our list
- public Form1(List<CardIndex> list)
- {
- foreach (CardIndex card in lOcI)
- {
- list.Add(card);
- }
- }
- //#2 method that get a list and adds to her our list
- public void showDtls1(List<CardIndex> list)
- {
- foreach (CardIndex card in lOcI)
- {
- list.Add(card);
- }
- }
- //#3 method that return our list
- public List<CardIndex> showDtls2()
- {
- return lOcI;
- }
- //#4 method that get listbox from form2 and adds to hem part of our list
- public void showDtls3(ListBox listbox)
- {
- foreach (CardIndex card in lOcI)
- {
- listbox.Items.Add(card.book);
- }
- }
- //#5 the fifth is the constructer of form2
- //here we will call to all methods and construter that transfer our method to form2
- private void showDtls_Click(object sender, EventArgs e)
- {
- // this code adds our list to listbox in our form, just for check
- // if the problom isn't in the code that adds to the listbox
- foreach (CardIndex card in lOcI)
- {
- listBox1.Items.Add(card.book);
- }
- //the form that we need to transfer to hem our list
- //#5 the constructer from form2
- //Form2 form2 = new Form2(lOcI);
- Form2 form2 = new Form2();
- form2.ShowDialog();
- // i call to all methods and constructer in the Form2_Load event
- form2.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement