-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: Tip for .net V2 winform developers...
PostPosted: Wed Feb 15, 2006 2:28 am 
Beginner
Beginner

Joined: Thu Dec 08, 2005 6:49 pm
Posts: 49
This has probably been mentioned before, but just in case it hasn't I thought I'd share.

Whilst looking for ways to waste time, I randomly stumbled upon the "Add New Data Source" screen under the Data menu. It contains not only the usual database and webservice sources, but a much more interesting one called "Object". Selecting this allows you to mark your domain objects as standard datasources for use in databinding.

Once you’ve marked your objects, you can simply drag and drop fields onto a form using the "Data Sources" window (Ctrl-Alt-D). A BindingSource component will be automatically added for each distinct source used and all you have to do is remember to set the DataSource property on the BindingSource when loading the form (eg, blogBindingSource.DataSource = blogObj).

You'll also notice that you can traverse through parent properties and easily bind to properties on those also (eg, "Parent.Name" or even "Suburb.State.Country.Name”).

If you already have controls on the form that you want to bind to, you can drag and drop from the "Data Sources" window on top of those existing fields to databind to the default property.

I was a little worried about using NHibernate at first, thinking that databinding would be so tedious compared to using typed datasets. This has just made my day.


Nathan


Top
 Profile  
 
 Post subject: Re: Tip for .net V2 winform developers...
PostPosted: Wed Feb 15, 2006 4:54 am 
Senior
Senior

Joined: Sat May 14, 2005 8:40 am
Posts: 130
Nathan Baulch wrote:
You'll also notice that you can traverse through parent properties and easily bind to properties on those also (eg, "Parent.Name" or even "Suburb.State.Country.Name”).


Are you sure about this? Many people already complained that it isn't possible to bind to to properties like 'Parent.Name' with the new 2.0 binding features.

_________________
Cuyahoga


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 15, 2006 9:11 am 
Beginner
Beginner

Joined: Thu Dec 08, 2005 6:49 pm
Posts: 49
Quote:
Are you sure about this?

Sure am! But only if you use the "Data Sources" window (Ctrl-Alt-D). It doesn't give you the option when using the combobox in the propertygrid under "(DataBindings)" on the control your binding (although you are able to type it in).

After binding a property, it will say something like "bindingSource1 - Parent.Name".


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 16, 2006 5:51 am 
Beginner
Beginner

Joined: Tue Jan 17, 2006 12:55 pm
Posts: 49
Works for WebControls too... I can use a method on a BusinessService class to populate the control via my ObjectDataSource and therefore do the whole thing declaratively.

I did find, however, that I didn't have enough control over the process so did decide to do it programatically anyway.

The main thing is that I can bind to objects and collections and this is the first step away from DataSet driven design that MS has given us.

Welcome to the world of Domain Driven Design!


Top
 Profile  
 
 Post subject: Re: Tip for .net V2 winform developers...
PostPosted: Fri Feb 17, 2006 8:14 am 
Beginner
Beginner

Joined: Fri Nov 11, 2005 1:04 pm
Posts: 22
Nathan Baulch wrote:
...I was a little worried about using NHibernate at first, thinking that databinding would be so tedious compared to using typed datasets. This has just made my day.


Nathan


Yes many of us are aware of this godsend in 2.0. If only we could find a way to get similar functionality in .Net 1.1


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 18, 2006 7:06 am 
Contributor
Contributor

Joined: Sun Jun 26, 2005 5:03 am
Posts: 51
Location: London, UK
There is a project underway, but I'm not sure how much progress has been made...

http://sourceforge.net/projects/objectviews

_________________
Paul Hatcher
NHibernate Team


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 18, 2006 10:20 am 
Senior
Senior

Joined: Sat May 14, 2005 8:40 am
Posts: 130
paulh wrote:
There is a project underway, but I'm not sure how much progress has been made...

http://sourceforge.net/projects/objectviews


The internals are fully functional, but the designer support has slowed down things a bit.

_________________
Cuyahoga


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 18, 2006 7:28 pm 
Beginner
Beginner

Joined: Thu Dec 08, 2005 6:49 pm
Posts: 49
martijnb wrote:
The internals are fully functional, but the designer support has slowed down things a bit.

Is there a list of differences between the ObjectView and BindingSource (from .net2) components anywhere?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 19, 2006 9:55 am 
Senior
Senior

Joined: Sat May 14, 2005 8:40 am
Posts: 130
Nathan Baulch wrote:
martijnb wrote:
Is there a list of differences between the ObjectView and BindingSource (from .net2) components anywhere?


The .NET 2.0 BindingSource does a lot that ObjectViews does. The only difference, I thought, was mapping 'deeper properties' like object.Parent.Name wasn't possible with the BindingSource, but earlier this thread it's mentioned that this seems possible. Therefore, if you're on .NET 2.0, it might be wise to stick to the available framework functionality.

_________________
Cuyahoga


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 28, 2006 11:41 am 
Newbie

Joined: Sat May 14, 2005 2:17 pm
Posts: 18
I'm playing with this right now. But...

When I put a datagridview on the screen and use your method to put put these fields in the grid
-Artikel.Name
-Artikel.Price

The grid is displaying the data so far so good.

Now I want to add a object property to the grid.
-Artikel.Country.Name

I can not do this. Do you know why?

I can drag Artikel.Country.Name to the form and an editbox is put on the screen and it refreshes so that part works.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.