Add BindingSource to a variable

brucelim80

Active member
Joined
Apr 20, 2006
Messages
35
Programming Experience
Beginner
Hi everyone,

Does anyone know how to write a code to map a BindingSource to a variable?
I have a bindingSource with the field username.


I only know how to map to a text box
deptcombo.DataBindings.Add("text", modibindingSource, "dept")
I will like to map it it to a variable.Can anyone provide me a code
?

Thank you
 
Firstly, that's not "mapping"; it's data-binding. Secondly, data-binding exists specifically to bind data to controls. If you aren't binding to a control then you aren't binding at all.

That said, there's nothing to stop you doing the data transfer manually. To push the data from the BindingSource to the variable you would handle the CurrentChanged and CurrentItemChanged events of the BindingSource. This would notify you when you need to update the variable and you simply get the appropriate value from the BindingSource's Current item. To go the other way you would need to expose the variable via a property and make sure you set it ONLY via that property. In the setter you would then assign the new value to the appropriate field of the BindingSource's Current item.
 
Hi everyone,

Does anyone know how to write a code to map a BindingSource to a variable?
I have a bindingSource with the field username.

the bindingsource is already a variable, called modibindingSource, of type "BindingSource"


Dim s as String = "Hello"

s is a variable

Youre asking how to put "Hello" in a variable. WEell, you already did it. --> s

I think you need to clarify your question
 
Back
Top