473,723 Members | 2,216 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BindingSource, Custom DataSource and DataGridView driving me mad!

Hi-

OK, I've got a DataGridView, I've created a BindingSource from one of my
Business Entity object (based on generated classes from EntitySpaces) I've
left the default column setup so that all the columns are displayed.

My DataSource objects are composed like this:

class Customer : esCustomer // where esCustomer is the EntitySpaces class
that was generated
{
public string PropTest
{
get{ return "PropTest!" ; }
}
}
esCustomer has some properties as well that were generated from my DB
schema, but from what I can see from teh code.. that shouldn't matter.

The problem is, all the properties that are in esCustomer are bound to the
DataGridView correctly, however none of the properties I add to Customer are
displayed.
I have checked and double checked that I'm indeed using the correct class
for the BindingSource object.

I've searched for events that I can subscribe to so I can try and debug the
binding process, but I'm not seeing anything that appears to expose the code
that is trying to fetch the properties.

I'm stuck and frustrated. Anyone want to suggest anything I should try?

Thanks for reading,
Steve Klett
Jun 20 '06 #1
2 9644
Steve,

Did you actually write a code to bind the binding source to an instance of
your Customer class. This is not done by the designer. The designer uses the
class to initialize the datagirdview, but doesn generate code to bind the
binding source to actuall instance of that class. It can do that because it
doesn't know where to get this instance from.

If you look at the InitializeCompo nent method you'll see that the binding
source is actually set up with the Type object of your class. This doesn do
much at run time.

What you need to do is in your form constructor or in some other place in
your code after the InitialzeCompon ent is called you need to add

this.customerBi ndingSource.Dat aSource = this.costumer;

where this.contumer is created and instialized instance of the Costumer
class.

BTW if you want the datagridview to reflect the changes made to the
properties of the business at run-time (after the grid is bound) your
business object needs to implement INotifyProperty Changed interface and fire
the event anytime a property changes

--
HTH
Stoitcho Goutsev (100)

"Steve" <sk**@skle.co m> wrote in message
news:OC******** ******@TK2MSFTN GP04.phx.gbl...
Hi-

OK, I've got a DataGridView, I've created a BindingSource from one of my
Business Entity object (based on generated classes from EntitySpaces) I've
left the default column setup so that all the columns are displayed.

My DataSource objects are composed like this:

class Customer : esCustomer // where esCustomer is the EntitySpaces
class that was generated
{
public string PropTest
{
get{ return "PropTest!" ; }
}
}
esCustomer has some properties as well that were generated from my DB
schema, but from what I can see from teh code.. that shouldn't matter.

The problem is, all the properties that are in esCustomer are bound to the
DataGridView correctly, however none of the properties I add to Customer
are displayed.
I have checked and double checked that I'm indeed using the correct class
for the BindingSource object.

I've searched for events that I can subscribe to so I can try and debug
the binding process, but I'm not seeing anything that appears to expose
the code that is trying to fetch the properties.

I'm stuck and frustrated. Anyone want to suggest anything I should try?

Thanks for reading,
Steve Klett

Jun 20 '06 #2
Very good information, thank you for taking the time to explain this! I'm
up and running now.
Have a good day,
Steve

"Stoitcho Goutsev (100)" <10*@100.com> wrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
Steve,

Did you actually write a code to bind the binding source to an instance of
your Customer class. This is not done by the designer. The designer uses
the class to initialize the datagirdview, but doesn generate code to bind
the binding source to actuall instance of that class. It can do that
because it doesn't know where to get this instance from.

If you look at the InitializeCompo nent method you'll see that the binding
source is actually set up with the Type object of your class. This doesn
do much at run time.

What you need to do is in your form constructor or in some other place in
your code after the InitialzeCompon ent is called you need to add

this.customerBi ndingSource.Dat aSource = this.costumer;

where this.contumer is created and instialized instance of the Costumer
class.

BTW if you want the datagridview to reflect the changes made to the
properties of the business at run-time (after the grid is bound) your
business object needs to implement INotifyProperty Changed interface and
fire the event anytime a property changes

--
HTH
Stoitcho Goutsev (100)

"Steve" <sk**@skle.co m> wrote in message
news:OC******** ******@TK2MSFTN GP04.phx.gbl...
Hi-

OK, I've got a DataGridView, I've created a BindingSource from one of my
Business Entity object (based on generated classes from EntitySpaces)
I've left the default column setup so that all the columns are displayed.

My DataSource objects are composed like this:

class Customer : esCustomer // where esCustomer is the EntitySpaces
class that was generated
{
public string PropTest
{
get{ return "PropTest!" ; }
}
}
esCustomer has some properties as well that were generated from my DB
schema, but from what I can see from teh code.. that shouldn't matter.

The problem is, all the properties that are in esCustomer are bound to
the DataGridView correctly, however none of the properties I add to
Customer are displayed.
I have checked and double checked that I'm indeed using the correct class
for the BindingSource object.

I've searched for events that I can subscribe to so I can try and debug
the binding process, but I'm not seeing anything that appears to expose
the code that is trying to fetch the properties.

I'm stuck and frustrated. Anyone want to suggest anything I should try?

Thanks for reading,
Steve Klett


Jun 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
6195
by: Jarod | last post by:
Hey I tried to use bindingSource created by wizard from dataGridView. I set it to bind data from my class I have public property "Source" that returns list of objects with property of "SampleText". Wizard created bindingDataSource object, and a column in my dataGridView but when I run this it doesn't seems to execute any data. I tried to bind dataGridView.DataSource to my object manually it works perfectly ;) I also tried to bind...
1
4537
by: TN | last post by:
I just don't get the BindingSource class when it is bound to a class. Consider this code snip: ..... Private bSource As New BindingSource() Private dgv As New DataGridView() Public Sub New() InitializeComponent()
1
3106
by: Pieter | last post by:
Hi, I have a custom List that inherits from BindingList. It has some methods overloaded, like the Add/Insert/etc to add and remove some eventhandlers when adding or removing an item T of the list. The problem happens when: - I use such a BindingList as DataSource for a BindingSource. - Add this BindingSource as DataSource for a DataGridView. - And go to the NewRow and add a new row in the DataGridView.
0
1581
by: Pieter Coucke | last post by:
Hi, I have a DataGridView, that contains a list of Articles, which can be added (automaticly via the AllowUserToAddRows) and changed by the user. The current item is also displayed in textboxes under the datagridview, to give more space for the user to change the item. But I'm getting some werid results with it: - When I add the first item to the DataGridView, and I change the values of the cells in the DataGridView, these values are...
4
16734
by: michael sorens | last post by:
I have successfully bound an XmlDocument to a DataGridView but all fields seem to be strings. I want to retrofit appropriate datatypes on some of the fields. Let me take this in 2 parts. Part I: I found the ValueType field, leading me to believe that I could say dataGridView.Columns.ValueType = typeof(Double); dataGridView.Columns.ValueType = typeof(Integer); etc.
7
13450
by: Mike | last post by:
i have a small difficulties with BindingSource and dataGridView bind db has properly opened and bind doesn't works. Unfortunately I didn't find any good example how to connect MS Access with dataGridView and BindSource class. Maybe something like this: DataTable dtResult = new DataTable(); dtResult = GetData(); // this line returns a error GetData doesn't exists!
3
1493
nev
by: nev | last post by:
I havah bindingnavigator onah form andah datagridview. I wanna binda grid to the bindingnavigator so that i can navigate thru the items using the bindingnavigator. dtt is programmatically filled with values dgv.datasource = dtt dgv displays data on the form beautifully. bindnav.bindingsource.datasource = dtt --> error binding a particular column so...
5
4940
by: jehugaleahsa | last post by:
Hello: I am sure this question comes up a lot. I need to disable the controls on my Windows forms so that when the BindingSource is empty some the controls bound to it will be disabled. This will make it clear to the user that they have to create a new item first before they start working. This needs to be an easy process because there are many, many forms.
2
4664
by: TamusJRoyce | last post by:
I am working on a group project where I do not have access to a BindingSource that is being passed through a function. The BindingSource's DataSource is set to a custom IBindingListView Collection. When I try to set IsNew on the BindingSource having the custom IBindingListView, the BindingSource IsNew remaines false. I have been able to do a test with my own IBindingListView being set on the BindingSource, and if I set IsNew before I set...
0
8741
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9241
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9160
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9090
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8062
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6685
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5996
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4504
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4764
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.