View Single Post
Old 05-29-2007   #2 (permalink)
Plamen Ratchev


 
 

Re: Manual population of listview

Normally you specify the content of the ListView by setting the ItemSource
property of the Items property. You can see good examples of that here:
http://msdn2.microsoft.com/en-us/lib....listview.aspx
http://blogs.msdn.com/atc_avalon_tea...23/537715.aspx

Alternatively you can add row by row, a brief step by step here:

1. Assuming you have a custom class (Employee) that exposes properties for
FirstName and LastName.
2. Add two GridView columns.
3. On the first one set col1.DisplayMemberBinding = new
Binding("FirstName");
4. On the second one set col2.DisplayMemberBinding = new
Binding("LastName");
5. Create an instance of your custom object, like:
Employee emp = new Employee();
emp.FirstName = "Joe";
emp.LastName = "Doe";
// Next add to the ListView
MyListView.Items.Add(emp);

That should do it.

HTH,

Plamen Ratchev
http://www.SQLStudio.com



My System SpecsSystem Spec