title: C# - Pass data between two forms (Windows Forms Application)
body: <p>I have a project in C# Windows Form application, in my project i have 2 screens, 1 - ListView to show datas, 2 - Formulary to get information and put on ListView, the main issue is, pass the information from Form2 to Form1.</p>
  
  <p>My logic:</p>
  
  <ul>
  <li>Get information from user on the Form2 and pass to other Class</li>
  <li>On Form1 get information from that other Class and add on ListView</li>
  </ul>
  
  <p>The issue:</p>
  
  <ul>
  <li>Object kind <code>ListViewItem</code> return null</li>
  </ul>
  
  <p>Form2: Get information from Form</p>
  
  <pre><code>    namespace Company
  {
      public partial class Register : Form
      {
          EmployeeDAO employeeDAO = new EmployeeDAO();
  
          public Register()
          {
              InitializeComponent();
          }
  
          private void btnRegister_Click(object sender, EventArgs e)
          {
              Employee employee = new Employee();
              employee.idEmployee = Convert.ToInt16(this.txtId.Text);
              employee.nameEmployee = this.txtName.Text;
              employeeDAO.insert(employee);
  
          }
  
      }
  }
  </code></pre>
  
  <p>My class DAO to get information from Form2 and pass to Form1: (I get information and put a ListViewItem and return it)</p>
  
  <pre><code>namespace Company
  {
      class EmployeeDAO
      {
          ListViewItem item = new ListViewItem();
  
          public void insert(Employee employee)
          {
              string id;
              string name;
              id = Convert.ToString(employee.idEmployee);
              name = employee.nameEmployee;
              String[] row = { id, name };
              item = new ListViewItem(row);
          }
  
          public ListViewItem read()
          {
              //This item are returning null
              return item;
          }
      }
  }
  </code></pre>
  
  <p>Form1 to show datas on a ListView: (I get the ListViewItem object and Add to ListView)</p>
  
  <pre><code>namespace Company
  {
      public partial class Main : Form
      {
  
          public Main()
          {
              InitializeComponent();
              lstEmployee.View = View.Details;
              lstEmployee.FullRowSelect = true;
              lstEmployee.Columns.Add("ID", 150);
              lstEmployee.Columns.Add("Nome", 150);
              insert();
          }
  
          private void insert()
          {
              EmployeeDAO employeeDAO = new EmployeeDAO();
              ListViewItem item = employeeDAO.read();
              if (item == null)
              {
                  //Always this block run
                  MessageBox.Show("No Item");
                  return;
              }
              else
              {
                  MessageBox.Show("Item");
                  lstEmployee.Items.Add(item);
              }            
          }
  
          private void btnRegister_Click(object sender, EventArgs e)
          {
              Register register = new Register();
              register.Show();
              this.Hide();
          }
      }
  }
  </code></pre>
  
  <p>Can someone kindly explain how to do this, and if is the correct method? 
  PS: im new on C# and OO.</p>