Creating class instances that populate forms in Visual Studio

I want to create instances of classes that I wrote in Visual Studio 2008, and then populate the list with these instances that are in the form that opens from Visual Studio. To give you an example, let's say what is in our solution class Employee. Using VS Extensibility I would like to open a form in VS that contains a listview. Then I would like to create 100 instances Employeepopulating the list and be able to edit their properties. Obviously, if I changed something in class Employeefor example: add a date of birth, then the list should be updated. Can someone provide any examples or links that would be helpful?

+3
source share
1 answer

Assuming I'm asking the right question, you have a form with a ListView, and when you open this form when it opens, you create 100 employee instances in that first step.

Start with a list of Employee arrays.

List<Employee> EmployeeList = new List<Employee>();

Fill out this list when loading the form.

private void Form1_Load(object sender, System.EventArgs e)
{
    for(int i = 0; i < 100; i++)
    {
       EmployeeList.Items.Add(new Employee());
    }

    // Bind EmployeeList to your ListView
    ListView.ItemSource = EmployeeList;
}

If you update EmployeeList and update the list, it should update it with the changed information.

+2
source

Source: https://habr.com/ru/post/1768386/


All Articles