Getting started with databinding the Winforms DataGridView with SelfService v3.5

Posts   
 
    
like2175
User
Posts: 83
Joined: 27-Mar-2006
# Posted on: 14-Nov-2012 13:41:38   

I have a Windows Form application. I have a DataGridView that I would like to bind (ultimately) to an LLBLGen Collection. When editing some of the columns I would like to use ComboBoxes bound (ulitmately) to filtered and sorted LLBLGen Collections.

Could someone explain in simple terms the best practice steps required to bind the DataGridView and Combo boxes. Should I be:

  1. Dragging my LLBLGenPro created DAL dll onto the toolbox, then dragging the collections onto my form then binding the grid and combo boxes to these?

  2. Adding a bindingSource, connecting that to a collection and binding the grid to the bindingSource. Should the Collection be created through Data - Add New Data Source?

  3. Using some other method?

If I want to be able to apply a sort and filter to the combo box data sources, where should this be done?

I am not sure the best practice way of doing this in 2012 with my setup of LLBLGenPro v3.5, C#, VS2010 (or VS2012) and .NET framework 4 or above.

I used option 1 with some success but kept getting errors when trying to open the Windows Form designer which I could only fix by re-adding the DAL .dll to the toolbox (surely this isn't necessary)

(coming from ASP.NET forms, this WinForms stuff is all a bit alien at the moment!)

Any help, or just a pointer to the most up to date document describing how to do this, would be gratefully received.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 14-Nov-2012 18:09:38   

To setup databinding at design time, it's recommended you use the Data sources feature in Visual Studio.NET. Create a Data Source based on an entity type in the generated code, e.g. CustomerEntity. Setup databinding using that data source, e.g. through dragging a BindingSource onto your form. When you set the DataSource property of that BindingSource to the Data Source you created of the entity type, you can design the control bound to the BindingSource. At runtime, set the DataSource property of the BindingSource instance to a fetched EntityCollection<T> instance. This will make sure the data shows up in the control bound to the BindingSource.

like2175
User
Posts: 83
Joined: 27-Mar-2006
# Posted on: 15-Nov-2012 09:33:36   

Walaa wrote:

To setup databinding at design time, it's recommended you use the Data sources feature in Visual Studio.NET. Create a Data Source based on an entity type in the generated code, e.g. CustomerEntity. Setup databinding using that data source, e.g. through dragging a BindingSource onto your form. When you set the DataSource property of that BindingSource to the Data Source you created of the entity type, you can design the control bound to the BindingSource. At runtime, set the DataSource property of the BindingSource instance to a fetched EntityCollection<T> instance. This will make sure the data shows up in the control bound to the BindingSource.

Thank you - just what I needed.