DennisHarding
Member
Nothing binds to my user control. It will bind to other controls.
code for UC property:
Binding the UC to a control works one way (CheckBox.checked changes UC)
Code for binding UC to CheckBox :
Code for binding CheckBox to UC (does not work; UC.IsOn changes but not CheckBox):
I am working with a Velleman K8055 project board that comes with a dll.
This one line of code works both ways (Vell.DO changes-Checkbox changes & checkbox changes-Vel.DO changes)
Code for Vel:
At this point I would be happy if my UC could be bound to at all,
but would prefer it working two way like the Vell control.
Any help would be greatly appreciated.
BTW, I've played around with the IsOn property a lot
trying to get it to work: Bindable, INotifyPropertyChanged, etc.
It only has to bind (work) at runtime, not at designtime.
Thanks a million for any help.
code for UC property:
VB.NET:
#Region "IsOn"
'Public Sub IsOnValue_Changed Handles
Public Sub Me_IsOnChanged() Handles Me.IsOnChanged
If IsOn = True Then
If OnImagevalue = Nothing Then
'MessageBox.Show("Control On Off True picture not set")
Else
PictureBox1.Image = Image.FromFile(OnImagevalue) 'Transparent
End If
'Me.BackColor = Color.OrangeRed
Else
If OffImagevalue = Nothing Then
'MessageBox.Show("Control On Off False picture not set")
Else
PictureBox1.Image = Image.FromFile(OffImagevalue)
End If
End If
End Sub
Public Event IsOnChanged() ' Bindable(True),
Public IsOnvalue As Boolean '
<Editor(GetType(INotifyPropertyChanged), GetType(UITypeEditor))> _
<Browsable(True), DebuggerBrowsable(True), _
Category("Misc"), Description("Gets/Sets when the control is off or on."), System.ComponentModel.Bindable(True)> _
Public Property IsOn() As Boolean
Get
IsOn = IsOnvalue
Return IsOnvalue
End Get
Set(ByVal Value As Boolean)
IsOnvalue = Value
RaiseEvent IsOnChanged()
End Set
End Property
#End Region '"IsOn"
Code for binding UC to CheckBox :
VB.NET:
UC1.DataBindings.Add(New Binding("IsOn", CheckBox2, "Checked"))
VB.NET:
CheckBox1.DataBindings.Add(New Binding("Checked", UC1, "IsOn"))
This one line of code works both ways (Vell.DO changes-Checkbox changes & checkbox changes-Vel.DO changes)
Code for Vel:
VB.NET:
K80551.DO1.DataBindings.Add(New Binding("Checked", CheckBox4, "Checked"))
but would prefer it working two way like the Vell control.
Any help would be greatly appreciated.
BTW, I've played around with the IsOn property a lot
trying to get it to work: Bindable, INotifyPropertyChanged, etc.
It only has to bind (work) at runtime, not at designtime.
Thanks a million for any help.