2009-10-14 9 views

Odpowiedz

21

Czy publiczna konstrukcja bez parametrów jest myClass? Jeśli nie, możesz wyprowadzić z BindingList<T> i zastąpić AddNewCore, aby wywołać twój konstruktor niestandardowy.

(edit) Alternatywnie - wystarczy owinąć listy w BindingSource i może pracować:

using System; 
using System.Windows.Forms; 
using System.Collections.Generic; 
public class Person { 
    public string Name { get; set; } 

    [STAThread] 
    static void Main() { 
     var people = new List<Person> { new Person { Name = "Fred" } }; 
     BindingSource bs = new BindingSource(); 
     bs.DataSource = people; 

     Application.Run(new Form { Controls = { new DataGridView { 
      Dock = DockStyle.Fill, DataSource = bs } } }); 
    } 
} 
+0

Że pracował :) Thank u very much. –

Powiązane problemy