The problem with this type of databinding is that ,at least for me, if i have a master-detail class the databinding feature show for the detail collection class information about the proxy that is use for lazy loading (even if i have explicitly loaded the details).
The need for design time binding is needed in order to create forms without even writing code as previous mentioned. If the project is small then it is ok but if you have to maitain a big project then this could be really time consuming. i think i have to create so called DTO classes that are only used for such task as databinding, serialization (WCF) and general implement task like dirty state tracking and so on. Has anybody found another approach??? On Feb 23, 2:06 pm, reflection <[email protected]> wrote: > 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 -~----------~----~----~----~------~----~------~--~---
