I did something like this in my program, too.

I simply created a BindingSource bound to the element I want to show
in the grid. I didn't find any way where I could pass a List<T> to the
BindingSource, but that's not a big problem.

I wrote this function:

public virtual void ListToGrid(DataGridView Target, List<YourClass>
Items)
    {
      BindingSource bindingSource = (BindingSource)Target.DataSource;

      //prevent redrawing the grid for every inserted item
      Target.DataSource = null;
      bindingSource.Clear();

      foreach (YourClass yourItem in Items)
      {
        bindingSource.Add(yourItem);
      }

      // reattach DataSource and draw the grid
      Target.DataSource = bindingSource;
      Target.AutoResizeColumns();
    }

This works fine for me. Though you have to take care if you remove
something from your List/BindingSource and stuff. But it works pretty
nice for me.

Hope that helps :)

Greetings,
Reflection

On Feb 21, 2:41 pm, mantzas <[email protected]> wrote:
> Hi,
>
> i  am seeking for a approach to Databind my nhibernate results
> (onjects,collection) to various controls.
>
> AFAIK there are mostly custom solution to this problem.
>
> Is there a pattern that i can follow?
>
> What about design time databinding using the object binding strategie
> of Visual Studio 2008?
>
> I' ve tried to implement my own collection without any success.
>
> Thx
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to