G
Guest
Hi all,
I’ve got a databinding inquiry. I’ve got a very simple example: a VB.Net
winforms app, with 3 components:
2 textboxes, and a button. Here are the handlers:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
TextBox1.DataBindings("Text").WriteValue()
TextBox2.DataBindings("Text").WriteValue()
My.Settings.Save()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
TextBox1.DataBindings.Add("Text", My.Settings, "val1", False,
DataSourceUpdateMode.Never)
TextBox2.DataBindings.Add("Text", My.Settings, "val2", False,
DataSourceUpdateMode.Never)
End Sub
As you can guess, there’s 2 settings: val1 and val2. If I just do regular
databinding which updates on its own (rather than
DataSourceUpdateMode.Never), no problems. But using the .never mode and doing
the update manually for each value with .writevalue, only one of the two
values gets written. For the other, the previous value remains. I’ve
discovered a possible reason:
Look at this stack trace:
WindowsApplication8.exe!WindowsApplication8.My.MySettings.set_Val1(String
Value = "apple") Line 65 + 0xe bytes Basic
[External Code]
WindowsApplication8.exe!WindowsApplication8.Form1.Button1_Click(Object
sender = {Text = "Button1"}, System.EventArgs e =
{System.Windows.Forms.MouseEventArgs}) Line 4 + 0x32 bytes Basic
[External Code]
Setting value 1 seems to trigger a refresh of the original value 2, which is
likely why it’s not getting the new value written. Is this because the two
share a binding context? What’s the thinking behind this? Why is it that this
problem doesn’t occur when I don’t set it to “.never�
PS: what is the “external code†in the above trace?
Thanks…
-Ben
I’ve got a databinding inquiry. I’ve got a very simple example: a VB.Net
winforms app, with 3 components:
2 textboxes, and a button. Here are the handlers:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
TextBox1.DataBindings("Text").WriteValue()
TextBox2.DataBindings("Text").WriteValue()
My.Settings.Save()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
TextBox1.DataBindings.Add("Text", My.Settings, "val1", False,
DataSourceUpdateMode.Never)
TextBox2.DataBindings.Add("Text", My.Settings, "val2", False,
DataSourceUpdateMode.Never)
End Sub
As you can guess, there’s 2 settings: val1 and val2. If I just do regular
databinding which updates on its own (rather than
DataSourceUpdateMode.Never), no problems. But using the .never mode and doing
the update manually for each value with .writevalue, only one of the two
values gets written. For the other, the previous value remains. I’ve
discovered a possible reason:
Look at this stack trace:
[External Code]WindowsApplication8.exe!WindowsApplication8.My.MySettings.get_Val2() Line 74 Basic
WindowsApplication8.exe!WindowsApplication8.My.MySettings.set_Val1(String
Value = "apple") Line 65 + 0xe bytes Basic
[External Code]
WindowsApplication8.exe!WindowsApplication8.Form1.Button1_Click(Object
sender = {Text = "Button1"}, System.EventArgs e =
{System.Windows.Forms.MouseEventArgs}) Line 4 + 0x32 bytes Basic
[External Code]
Setting value 1 seems to trigger a refresh of the original value 2, which is
likely why it’s not getting the new value written. Is this because the two
share a binding context? What’s the thinking behind this? Why is it that this
problem doesn’t occur when I don’t set it to “.never�
PS: what is the “external code†in the above trace?
Thanks…
-Ben