How to use the Bindingsource of form A to a form B

Onyx

Member
Joined
Jul 14, 2006
Messages
5
Programming Experience
Beginner
Hello, as the title describes it, I trying to build an application in which the user sees the info relative to one client on form A and then if he wants more details on one particular topic, lets say all the sales made by a clients or the calls he made to the company and so forth, well if he wants more details, he click on the details button and a new form pops out displaying the correct info binded to that specific client...

:eek: My problem:eek: is that I don't know how to use the binding source of form A to attach the correct info in form B. I want the two forms to be linked with the same bindingsource

thanks in advance all;)
 
thanks it's a great article, and it will be of some use for me! But maybe I'm not looking at the solution correctly. What I want to do is to use the BindingSource of Form A into form B, it's not discussed of how to use inbetween form's bindingsources... is it possible at all ?

thanks again
 
It seems that form A can access form B's controls and visa versa.

You could also have seperate controls on each form bound to the same

data (carefully) . So I'm confused about what you need or I'm just

to new to this to understand.
 
A form is an object, a control is an object and a BindingSource is an object. Everything is an object in VB.NET. You access any members of a form the same way, whether it's a control, a BindingSource or something else. If you've learned how to access the controls of one form from another from that tute then you've learned how to access a BindingSource because objects are objects and they are all handled the same way.
 
zekeman said:
It seems that form A can access form B's controls and visa versa.

You could also have seperate controls on each form bound to the same

data (carefully) . So I'm confused about what you need or I'm just

to new to this to understand.

In my case, I succeeded to access A's classes and controls from form B... what I'm not able to do is bind let's say a textbox on B, with the same binding source as on form A, so when I open form B, the data showed up is connected to the data that was on form A... basically, that's what I'm trying to do

I guess I'm not just quite there yet !

thanks again
 
If you wanted to get the text from a TextBox on formA into a TextBox on formB then you do something like this on formB:
VB.NET:
Me.TextBox1.Text = myFormA.TextBox1.Text
If you wanted to bind a BindingSource on formA to a DataGridView on formB then you'd do something like this:
VB.NET:
Me.DataGridView1.DataSource = myFormA.BindingSource1
The principle is exactly the same in each case. Of course, in both cases it would be bad practice to make the TextBox or the BindingSource public and fully exposed like that. You should rather pass the objects you want to use via properties or methods. Still though, whether you're passing a TextBox, a String or a BindingSource, and object is an object and they all get treated the same way.
 
ok, thanks, that I am able to accomplish, in your example you bind a datagrid view, thats cool because in the datagrid I am able to show all the data that is bounded to the datasource, but if I want to display only the bounded item in a column, lets say I want to display it in a textbox, that's the problem I get !

I'm not able to retrieve only the specified column in the textbox like in the property windows in the design mode


hope I Made my self clear and the question is not to heavy!

thanks again
 
Onyx, do not confuse DataGrid control and DataGridView control, they are different controls. When you are using .Net 2.0 you are usually better off using the DataGridView control.
 
Everything you do in the Properties window is simply translated to code by the IDE. When you create a data-binding in the Properties window for a TextBox it simply writes code to create that binding:
VB.NET:
myTextBox.DataBindings.Add("Text", myBindingSource, "ColumnName")
 
thanks all

I understand better how databinding works between forms, still get some nasty difficulty but I guess that'll come with experience

thanks again
 
Back
Top