0

Hi I am creating a simple windows forms app to for an assignment to register staff in a hospital and display it on a data grid, I don't know how to move the list that gets created to another form, any suggestions? here is the code for one of them and the interface. the first form is the button to open different roles and below it the data grid box with a button above to make it display the data.

public partial class formDoctor : Form
{
    public formDoctor()
    {
        InitializeComponent();
    }

    ListViewDoctor lvDoc = new ListViewDoctor();

    private void formDoctor_Load(object sender, EventArgs e)
    {
        cboCountyDoctor.DataSource = Enum.GetValues(typeof(Counties));
    }
     private void btnSubmitDoctor_Click(object sender, EventArgs e)
    {
        string fn, sn, ads, cy, age, pn, mail,hol;
        fn = txtFnDoctor.Text;
        sn = txtSnDoctor.Text;
        ads = txtAddressDoctor.Text;
        cy = cboCountyDoctor.SelectedItem.ToString();
        age = txtAgeDoctor.Text;
        pn = txtPhoneDoctor.Text;
        mail = txtEmailDoctor.Text;
        hol = "Lung";
        if (cbHeartDoc.Checked)
        {
            hol = "Heart";
        }
      

        lvDoc.AddToListDoctor(fn, sn, ads, cy, age, pn, mail,hol);

        

        txtFnDoctor.Clear();
        txtSnDoctor.Clear();
        txtAddressDoctor.Clear();
        txtAgeDoctor.Clear();
        txtPhoneDoctor.Clear();
        txtEmailDoctor.Clear();

    }
}

}

form to add doctor

  • Does this answer your question? [Communicate between two windows forms in C#](https://stackoverflow.com/questions/1665533/communicate-between-two-windows-forms-in-c-sharp) – JohnG Mar 28 '22 at 14:57
  • It is unclear what a `ListViewDoctor` is or what other form you want to pass the (unknown) List to. Can you clarify any of this? – JohnG Mar 28 '22 at 15:00
  • @JohnG Thanks for the comment, I did have a read and I still don't understand. I want to know how I could pass one list from one form to another to create a new list if that makes sense. ListViewDoctor is a class that I made which contains a constructor AddToListDoctor. – juhyun jung Mar 28 '22 at 17:54

0 Answers0