By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,009 Members | 2,821 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,009 IT Pros & Developers. It's quick & easy.

Binding same column to multiple properties

P: n/a
Hi,

Let's say I bind the same column to multiple properties of one control (or
even to the same property of several controls).

If a user changes the value of the property in one control - I would like to
take that value, and put it in the data source, and have anything else bound
to this column get updated with the new value.

However, called EndCurrentEdit, resets the value to the original, and
basically throws out the new value.

If however, I updated the value in all the other controls/properties bound
to this column, to the new value just entered - only then does
EndCurrentEdit put the new value into the datasource.

What I need is to have EndCurrentEdit accept the value and put it in the
datasource, so that then I can call Refresh, to have anything else bound to
the column receive the new value. If I have to put the value in myself in
every control bound to the column, that seems to defeat the purpose.

How can this be done?

Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi Marina,

I am not sure if I understand your question (Because it is you I think it is
not an easy question), however did you already see what using different
dataviews can do for you, that I used with success.

(You should look in the adonet group, Jon (he tested somehing and now) is
completly to the other side (ours) about dispose in my opinion)

Cor
Nov 20 '05 #2

P: n/a
Here is the thing:

If I have 2 controls, each with a textbox. I bind the same column to each of
the textbox's Text properties. Then everything works as expected.

However, if one of the properties is another property (say a custom
property), then suddenly calling EndCurrentEdit does not work.

This is a very dynamic form, and I do not know which control with which
property will get bound to what. Because of that, i would need a separate
dataview for each binding - which has got to be expensive.

It seems to come down to the name of the property. As long as both
properties are the Text property, then it's all fine. If one of the
properties is a custom property I wrote, then changing the value of the
column in the Text property and calling EndCurrentEdit, discards the
changes, instead of sending them back to the datasource.

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Oo*************@TK2MSFTNGP09.phx.gbl...
Hi Marina,

I am not sure if I understand your question (Because it is you I think it is not an easy question), however did you already see what using different
dataviews can do for you, that I used with success.

(You should look in the adonet group, Jon (he tested somehing and now) is
completly to the other side (ours) about dispose in my opinion)

Cor

Nov 20 '05 #3

P: n/a
Hi Marina,

I think there is to much to gues in it for me, did you ever see that strange
behaviour of binding the text property from a combobox, your problem sounds
the same for me.

I never succeeded in getting a real answer on that, that did solve or
workaround the problem.

Cor
Nov 20 '05 #4

P: n/a
No, sorry, this is really completely different. When you are talking about a
combox, you are talking about changing the position of the current row -
this isn't what i am doing at all, this is all on the same row.

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eb****************@TK2MSFTNGP12.phx.gbl...
Hi Marina,

I think there is to much to gues in it for me, did you ever see that strange behaviour of binding the text property from a combobox, your problem sounds the same for me.

I never succeeded in getting a real answer on that, that did solve or
workaround the problem.

Cor

Nov 20 '05 #5

P: n/a
Hi Marina,

This does work in my opinion fine.
(I places some buttons in your code to test it)

Cor

\\\
Dim dt As New DataTable
Dim dv1 As DataView
Dim dv2 As DataView
Private Sub Form2_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
dt.Columns.Add("MyColumn")
Dim row As DataRow = dt.NewRow
row(0) = "TestValue"
dt.Rows.Add(row)
dv1 = New DataView(dt)
dv2 = New DataView(dt)
MyTextBox1.DataBindings.Add("Text", dv1, "MyColumn")
MyTextBox1.DataBindings.Add("MyProperty", dv2, "MyColumn")
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
MyTextBox1.Text = "TextValue"
Me.BindingContext(dv1).EndCurrentEdit()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
MyTextBox1.MyProperty = "PropValue"
Me.BindingContext(dv2).EndCurrentEdit()
End Sub
////
Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.