Advertisement
Guest User

Untitled

a guest
Oct 17th, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.58 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Diagnostics;
  10.  
  11. namespace laibery
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         // the list that we need to transfer to form2
  21.         // lOcI = list Of card Index, from now i'll call her "our list"
  22.         public List<CardIndex> lOcI = new List<CardIndex>();
  23.  
  24.         private void saveDtls_Click(object sender, EventArgs e)
  25.         {
  26.             lOcI.Add(new CardIndex(book.Text, writer.Text, price.Text, quantity.Text));
  27.             book.Text = writer.Text = price.Text = quantity.Text = "";
  28.         }
  29.        //all the constructer & method that transfer our list to form2
  30.  
  31.         //#1 constructer that get a list and adds to her our list
  32.         public Form1(List<CardIndex> list)
  33.         {
  34.             foreach (CardIndex card in lOcI)
  35.             {
  36.                 list.Add(card);
  37.             }
  38.         }
  39.  
  40.         //#2 method that get a list and adds to her our list
  41.         public void showDtls1(List<CardIndex> list)
  42.         {
  43.             foreach (CardIndex card in lOcI)
  44.             {
  45.                 list.Add(card);
  46.             }
  47.         }
  48.  
  49.         //#3 method that return our list
  50.         public List<CardIndex> showDtls2()
  51.         {
  52.             return lOcI;
  53.         }
  54.  
  55.         //#4 method that get listbox from form2 and adds to hem part of our list
  56.         public void showDtls3(ListBox listbox)
  57.         {
  58.             foreach (CardIndex card in lOcI)
  59.             {
  60.                 listbox.Items.Add(card.book);
  61.             }
  62.         }
  63.  
  64.         //#5 the fifth is the constructer of form2
  65.  
  66.       //here we will call to all methods and construter that transfer our method to form2
  67.         private void showDtls_Click(object sender, EventArgs e)
  68.         {
  69.             // this code adds our list to listbox in our form, just for check
  70.             // if the problom isn't in the code that adds to the listbox
  71.             foreach (CardIndex card in lOcI)
  72.             {
  73.                 listBox1.Items.Add(card.book);
  74.             }
  75.  
  76.           //the form that we need to transfer to hem our list
  77.           //#5 the constructer from form2
  78.           //Form2 form2 = new Form2(lOcI);
  79.             Form2 form2 = new Form2();
  80.             form2.ShowDialog();
  81.           // i call to all methods and constructer in the Form2_Load event
  82.             form2.Close();
  83.         }
  84.     }
  85.  
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement