Can mulitple controls use a single binding object?

M

moondaddy

(this is a re-post as I'm now posting via my new msdn alias)

I'm going to create a binding object and bind the format event to a control.
I wanted to be able to re-use the binding object again for other controls,
or do I need to create a new binding object for each contorl? This is a
small example:



Dim bnd As Binding = txtBirthDate.DataBindings("Text")
AddHandler bnd.Format, AddressOf DataFormat

can I use bnd for other controls like:
txtDate2
and
txtDate3?

or will i need to create a binding object for each control like this:

Dim bnd2 As Binding = txtDate2.DataBindings("Text")
AddHandler bnd2.Format, AddressOf DataFormat

Dim bnd3 As Binding = txtDate3.DataBindings("Text")
AddHandler bnd3.Format, AddressOf DataFormat


Thanks.
 
K

Kevin Yu [MSFT]

Hi moondaddy,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to know if a Binding object
can be reused among several controls. If there is any misunderstanding,
please feel free to let me know.

As far as I know, we cannot do that. a Binding object is unique by a data
source and a control's property. So please use the binding object as the
following:

Dim bnd2 As Binding = txtDate2.DataBindings("Text")
AddHandler bnd2.Format, AddressOf DataFormat

Dim bnd3 As Binding = txtDate3.DataBindings("Text")
AddHandler bnd3.Format, AddressOf DataFormat

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
K

Kevin Yu [MSFT]

You're welcome, moondaddy.

Thanks for sharing your experience with all the people here. If you have
any questions, please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top