G
Grim Rob
I am using .NET Framework v2. I am binding properties to controls
using complex binding. However until you tab off each control to lose
focus the object being bound to is not updated. To get round this I am
using SendKeys to tab on and off the control. This works fine but you
have to put the sendkeys code in every event handler being bound to
which is horrible. Is there a better way?
Here are some code fragments.
Protected m_BindingSource As BindingSource = New BindingSource
UpdateBinding(chkWeek1Month1AtLeaving, "Checked",
m_BindingSource, "Week1Month1IndicatorAtLeaving")
Protected Sub updateBinding(ByVal c As Control, ByVal prop As
String, ByVal BindingSource As BindingSource, ByVal dataMember As
String)
If c.DataBindings(prop) IsNot Nothing Then
c.DataBindings.Remove(c.DataBindings(prop))
c.DataBindings.Add(prop, BindingSource.DataSource,
dataMember)
End Sub
Private Sub chkWeek1Month1AtLeaving_CheckedChanged(ByVal sender
As Object, ByVal e As System.EventArgs) Handles
chkWeek1Month1AtLeaving.CheckedChanged
SendKeys.Send(vbTab + "+" + vbTab)
End Sub
using complex binding. However until you tab off each control to lose
focus the object being bound to is not updated. To get round this I am
using SendKeys to tab on and off the control. This works fine but you
have to put the sendkeys code in every event handler being bound to
which is horrible. Is there a better way?
Here are some code fragments.
Protected m_BindingSource As BindingSource = New BindingSource
UpdateBinding(chkWeek1Month1AtLeaving, "Checked",
m_BindingSource, "Week1Month1IndicatorAtLeaving")
Protected Sub updateBinding(ByVal c As Control, ByVal prop As
String, ByVal BindingSource As BindingSource, ByVal dataMember As
String)
If c.DataBindings(prop) IsNot Nothing Then
c.DataBindings.Remove(c.DataBindings(prop))
c.DataBindings.Add(prop, BindingSource.DataSource,
dataMember)
End Sub
Private Sub chkWeek1Month1AtLeaving_CheckedChanged(ByVal sender
As Object, ByVal e As System.EventArgs) Handles
chkWeek1Month1AtLeaving.CheckedChanged
SendKeys.Send(vbTab + "+" + vbTab)
End Sub