How to bind a List of a DataObject to a Grid with BindingSources?
- by citronas
In an assembly I created a class like the following:
[DataObject(true)]
public class A
{
public int Foo{get;set;}
[DataObjectMethod[DataObjectMethodType.Select)]
public static List<A> GetAllA(string ConnectionString)
{
// return filled List<A>
}
}
Now I want to display this List with a Gridcontrol under Winforms. I though of a DataGrid.
Though I'm coming from ASP.net I'd first think of
this.dataGridView1.DataSource = A.GetAllA(ConnectionString)
Works, but I'd prefer a better databinding with BindingSources. (Because I've always heard that thats the way to go)
I managed to drop a BindingSource onto the form and set the DataSource property to class A.
But where can I set the SelectMethod and its parameters? If I set DataSource property of the dataGridView to the BindingSource, it will only display an empty line.
Is this the right way to go? Will it only require some additional clicks in the wizard, or do I need to read tons of documentation to get this working?