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 / .NET Framework / New Users / March 2006

2.0 BindingSource

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
William Sullivan - 01 Mar 2006 19:30 GMT
The question I have is how to connect an instance variable to a binding
source.  In the IDE, I can create a new Data Source pointing to an object in
my class.  It creates the source based on the definition of the class, not a
specific instance of that class on, say, a form. I can drag that Data Source
definition onto the form and create a DataGrid and an associated
BindingSource object.  Great.  Sweet.  But how do I link that DataGrid to the
instance of that object in the form, so that data in the instance of the
object is displayed in the grid, and changes in the grid are serialized to
the object?  I see there is  a DataSource property in the BindingSource, but
in the visual editor, that is set to the DataSource in the solution...
Christian Schwendtner - 02 Mar 2006 10:13 GMT
Hi William

> I see there is  a DataSource property in the BindingSource,
> but in the visual editor, that is set to the DataSource in the
> solution...

In the visual editor die DataSource property of the BindingSource
object is set to the type of the object which should be displayed (in
the designer, you select a Type within your project). If you look at
the designer generated code there is something like (let´s take a
class named "Person" as DataSource):

myBindingSource.DataSource = typeof(Person);

--> so the designer is able to display (generate) the right columns for
you and you see them in the designer (in your grid).

When you want to display some data in the grid (eg when a button is
pressed) you do the following:

... buttonXYZ_pressed(...) {

 // load data
 ICollection<Person> persons = LoadPersons(.....);

 // bind it to the BindingSource
 myBindingSource.DataSource = persons.
}

Did I understand your problem right?

hth,
 Chris
William Sullivan - 02 Mar 2006 15:26 GMT
Yes, you do.  It was unclear to me that I should use the same property.  The
way it comes from the designer led me to believe that the DataSource, being
assigned a type object, was used to map the schema (so to speak) of the
object...  Thanks.

> Hi William
>
[quoted text clipped - 29 lines]
> hth,
>   Chris

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.