views:

129

answers:

1

Hi

I want to instantiate classes that I have written in Visual Studio 2008 and then populate a listview with these instances which resides in a form that opens up from within Visual Studio. To give you an example let's say we have a class Employee within our solution. Using VS Extensibility I would like to open a form in VS that contains a listview. Then I would like to create 100 Employee instances populating the listview and be able to edit their properties. Obviously if I change something in the class Employee e.g: add an attribute date of birth, then the listview will have to be updated. Can anyone provide any examples or links that would be helpful?

+2  A: 

Assuming I am uderstanding the question correctly, you have a form with a ListView, and when you open that form on opening it you create 100 instances of employee so first step.

Start with an array list of Employee.

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

Populate this list when the form loads.

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 refresh the listview it should update it with the changed information.

kyndigs
Sorry that is not the question. How do you do the above using the Extensibility Framework so that you load the Employee instances within a form launched from inside VS?
Dimitris