473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Bindingsource.datasource Error in desing

Hi misters,
I used the Data Sources window to drop a custom object onto the designer
surface. It created a BindingSource and BindingNavigator as a result.

When I open the Properties window on the BindingSource, I see DataSource
property set to the object I created.

However, when I try to dropdown the DataSource property, I get the message:

"Object reference not set to an instance of an object". The title of the
messagebox is "Microsoft Visual Studio".

So I cannot change the DataSource, I went into the designer file and
removed the DataSource property of the BindingSource and went back into the
designer. It showed the DataSource as (none) as I expected.

But the same error message occurs when I try to change the property with the
dropdown box.

What is going on? Any help will be very grateful

Thanks in advance, regards
--
http://www.alhambra-eidos.es/web2005/index.html
www.kiquenet.net
http://www.setbb.com/putainformatica...opic.php?p=843
www.trabajobasura.com/solusoft

Jun 27 '08 #1
1 3568
Hi Alhambra,

I'm suspecting the BindingSource is created using a Type as DataSource
instead of an object instance. Designer created BindingSources may need some
manual code to be properly initialized.

I don't know too much about the designer features as I never use it, but it
is easy to create (and in my opinion far easier to use) in code.

Sample code:

public Form1()
{
InitializeComponent();

BindingSource source = new BindingSource(new MyClass(), "MyListProperty");
listBox1.DataSource = source;
listBox1.DisplayMember = "MyProperty";
textBox1.DataBindings.Add("Text", source, "MyProperty");
}

class MyClass
{
private List<MySubClass_myListProperty = new List<MySubClass>();

public List<MySubClassMyListProperty
{
get { return _myListProperty; }
set { _myListProperty = value; }
}

public MyClass()
{
MyListProperty.Add(new MySubClass("Hello"));
MyListProperty.Add(new MySubClass("And"));
MyListProperty.Add(new MySubClass("Goodbye"));
}
}

class MySubClass
{
private string myProperty;

public string MyProperty
{
get { return myProperty; }
set { myProperty = value; }
}

public MySubClass(string text)
{
MyProperty = text;
}
}
--
Happy Coding!
Morten Wennevik [C# MVP]
"Alhambra Eidos Kiquenet" wrote:
Hi misters,
I used the Data Sources window to drop a custom object onto the designer
surface. It created a BindingSource and BindingNavigator as a result.

When I open the Properties window on the BindingSource, I see DataSource
property set to the object I created.

However, when I try to dropdown the DataSource property, I get the message:

"Object reference not set to an instance of an object". The title of the
messagebox is "Microsoft Visual Studio".

So I cannot change the DataSource, I went into the designer file and
removed the DataSource property of the BindingSource and went back into the
designer. It showed the DataSource as (none) as I expected.

But the same error message occurs when I try to change the property with the
dropdown box.

What is going on? Any help will be very grateful

Thanks in advance, regards
--
http://www.alhambra-eidos.es/web2005/index.html
www.kiquenet.net
http://www.setbb.com/putainformatica...opic.php?p=843
www.trabajobasura.com/solusoft
Jun 27 '08 #2

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

Similar topics

3
by: silesius | last post by:
Hi All, I have two pagetabs. One pagetab is used to display a parent record and the other is suppose to display 3 related child records from another table. I can display the parent records just...
0
by: David McCrory | last post by:
Does anyone have a good example of using the Find() or Filter() methods of the BindingSource. I am binding to an array of objects and not having any luck getting these functions to work. ...
1
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()...
1
by: Leonardo | last post by:
Hi. I'm trying to build my first application with database access using VB 2005. I'm a VB 6 programmer and learning everything again has been challenging. I managed to write a code using some tips...
0
by: mollyf | last post by:
I've got a combo box that I want to bind a collection to. I got the error "Complex Data Binding accepts as a data source either an IList or an IListSource" so I tried using the BindingSource,...
7
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...
3
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...
5
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...
2
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....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...

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.