Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

VS 2008 Databindings for label on a winform usercontrol

$
0
0
I'm creating a usercontrol for a winform app that contains two labels, one as a header and the other one needs to bind to a datasource through Me.usercontrol1.databindings.add(). I'm a novice in usercontrol designing so I searched on internet to find how to make a databindings for my control. I realized that I need to use ControlBindingsCollection but I don't know exactly how.

I found following codes and added to my usercontrol :

Code:

Private bindingContext_ As BindingContext
Private dataBindings_ As ControlBindingsCollection
Public Overrides Property BindingContext() As BindingContext
    Get
        If bindingContext_ Is Nothing Then
            bindingContext_ = New BindingContext()
        End If
        Return bindingContext_
    End Get
    Set(ByVal value As BindingContext)
        bindingContext_ = value
    End Set
End Property
<DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
Public Overloads ReadOnly Property DataBindings() As ControlBindingsCollection
    Get
        If dataBindings_ Is Nothing Then
            dataBindings_ = New ControlBindingsCollection(Me)
        End If
        Return dataBindings_
    End Get
End Property

Now I can set usercontrol1.databindings parameters but there's obviously something missing because I need to connect a single returning value from this binding to label2.Text in my usercontrol and I don't know how.

Is there anybody to help me solve my problem ?

Thanks in advance.

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>