Monday, April 11, 2011

Databound User Controls in .NET

I am looking for some information on how to properly implement data binding on a user created control.

My UserControl contains a Textbox, a Button, and a MonthCalendar. I am able to databind to the Textbox inside of my user control, however, I want to implement the databinding on the UserControl itself, and not reference to textbox inside the control.

I have attempted to set a Property as follows:

  <System.ComponentModel.Bindable(True)> _
Public Property BoundDate() As DateTime
    Get
      Return _currentSelectedDate
    End Get
    Set(ByVal value As DateTime)
      SetDateTime(value, True)
    End Set
  End Property

However, when I add a binding source to the control, the field does not populate with the data, it remains blank. Do I need to do something to make the data appear afterwards?

Can anyone direct me to a good tutorial, or if possible, explain it here. The project is written in VB.NET.

EDIT: I am implementing the DefaultBindingPropertyAttribute

From stackoverflow

0 comments:

Post a Comment