473,472 Members | 2,224 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Getting a control's data bindings?

How do I get the data bindings for a control that is bound at design time?

I'm binding a DataGridView control to a data source at design time, using a
BindingSource control. I set the grid's DataSource property to the
BindingSource control, which the Data Source Configuration Wizard created
for me.

The data binding works fine when I run the app, but I can't get a reference
to the DataGridView's data bindings.

At runtime, when I check the grid's DataBindings.Count, I get zero back--no
data bindings. That can't be, since the bound grid is displaying data, just
like it's supposed to. And I get this result whether I check in the form
constructor, the form load event handler, or at any time after that.

The form's designer code doesn't contain any calls to DataBindings.Add(),
and it doesn't declare any Binding objects. But still the application works.

What's going on here? Am I looking in the wrong place for the grid's
bindings collection? How do I get a reference to the individual bindings, so
that I can work with them the way that I would work with a Binding object
that I had declared in code?

Thanks in advance.

--
David Veeneman
Foresight Systems

Jul 11 '06 #1
1 2088
I found my answer (thanks to Brian Noyes, author of "Data Binding With
Windows Forms 2.0)--a worthwhile read).

Only 'simple' data binding (labels, text boxes, and the like) creates
Binding objects. 'Complex' data binding (grids, list boxes, combos, and the
like) does not create them. So, when binding to a grid, there are no Binding
objects to get.

Brian's book has a fairly detailed discussion of how to work with the
DataGridView in data binding scenarios. The book is worth it for that
chapter alone.

--
David Veeneman
Foresight Systems
Jul 12 '06 #2

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

Similar topics

1
by: Arthur Chereau | last post by:
Hi, I'm trying to setup viewcvs to work with subversion 1.2.0 on Linux with Python 2.4.1. The last viewcvs (from CVS) needs subversion python bindings. I installed swig and built subversion from...
2
by: RSB | last post by:
Hi Every one, I am currently using Visual Studio .Net and trying to open a project from SourceSafe and once i open the project for the first time i get the following error/warning... "The...
2
by: Martin | last post by:
Hi, I want to create a number of ascx controls with edit and view modes. Previously I have put two panels in the ascx - one for view (with label subcontrols), and one for edit (with text box...
1
by: Gunjan Garg | last post by:
Hello All, I am working to create a generic datagrid which accepts a datasource(ListData - This is our own datatype) and depending on the calling program customizes itself for sorting,...
0
by: AMDRIT | last post by:
Hello everyone, VB2003-Winforms I have a class object (testclass), that I would like to bind parts of to two custom controls (control1 and control2). The testclass is stored in a hash table...
9
by: Jamie Risk | last post by:
I have a form with controls that bind to an object declared in the form. I have a communications class that is receiver driven. (to get data I have to send a command). How can I have the...
5
by: bz | last post by:
Hi, I create a class that retrieves a number of records from database. Internally, the class store the returned data in a datatable / datareader. I would like to bind a listbox to that class (to...
6
by: parez | last post by:
Is there anyway i can find out if a control is an input control (textbox,radiobutton,checkbox,dropdown etc) and not a panel,group box etc. I am trying to implement "You have unsaved data on the...
2
by: Steven Cheng | last post by:
Hi Gary, As for the setting you mentioned, it is used to custimze the received data size limitation of WCF binding(such as NetTcpBinding or HttpBinding). After you have definite a customized...
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
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...
0
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...
0
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,...
0
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...
0
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...
0
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.