Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

How to use objects for a DataGridView

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sin Jeong-hun - 01 Mar 2008 12:57 GMT
Visual Studio .NET lets me to choose an object type (not an instance)
for the datasource of a datagridview control. Then it automatically
generates a  ~~~bindingsource (~~~ is the object type name) component.
But I don't understand how to use it, I searched Google for this, but
couldn't find a tutorial or something. How can I actually set an
instance of a collection object for the datagridview? If there is a
tutorial page for this task, please direct me there. Thank you.
Sin Jeong-hun - 01 Mar 2008 13:20 GMT
> Visual Studio .NET lets me to choose an object type (not an instance)
> for the datasource of a datagridview control. Then it automatically
[quoted text clipped - 3 lines]
> instance of a collection object for the datagridview? If there is a
> tutorial page for this task, please direct me there. Thank you.

I found that the reason nothing came up on the control was that my
object has no properties but public fields. I created a property and
it was shown. I wonder if I have to make them all properties instead
of public fields, because that object has no operations and doesn't
need to validate the value of its public fields.
Marc Gravell - 01 Mar 2008 23:23 GMT
> I wonder if I have to make them all properties instead
> of public fields, because that object has no operations and doesn't
> need to validate the value of its public fields.

The standard approach is, indeed, to use properties. Even if you don't
have validation.

With C# 3 you can make this as easy as fields using the new auto-
implemented property syntax:

public int Foo {get;set;}

I *strongly* recommend using properties. However, I have seen a
TypeDescriptionProvider implementation that exposed the fields via
runtime PropertyDescriptors, which allows binding to property-grids,
data-grid-view, etc. But I don't recommend it.

Marc
Michel Walsh - 03 Mar 2008 19:58 GMT
If you still can put you hand on it, this book has 2 nice chapters about
data source binding:

http://www.amazon.com/Windows-Forms-Programming-Microsoft-Development/dp/0321267
966/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1204574054&sr=1-1


It is a kind of 'historical progression' about data binding, but it may help
to understand the mechanic behind, which can be useful, on occasions.

Vanderghast, Access MVP

> Visual Studio .NET lets me to choose an object type (not an instance)
> for the datasource of a datagridview control. Then it automatically
[quoted text clipped - 3 lines]
> instance of a collection object for the datagridview? If there is a
> tutorial page for this task, please direct me there. Thank you.

I found that the reason nothing came up on the control was that my
object has no properties but public fields. I created a property and
it was shown. I wonder if I have to make them all properties instead
of public fields, because that object has no operations and doesn't
need to validate the value of its public fields.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.