I want to bind the properties of a class directly
to controls in a winform. I know it can be done in VB.net but I just dont know how. Can someone helps and/or provide an example please
Binding as far as i know it refers to the binding of data from a database onto a control.
In laymans terms... when you change records all the textboxes and labels generate text automatically from the database (only if you bind all the controls first)
As far as accomplishing what you wish to do...
you could inherit from the UserContrl class.
you do not want to just type this in below the class declaration!!!!
go to Project on the menu
click Add User Control
Your new control will contain properties of a regular control plus whatever you add...
To display these properties during design time when the form is drawn you should use the system.component.componentmodel namespace (the syntax for this is strange i can send an example if you wish) Add it before the delclaratoin of a property
You can virtually bind to almost any object in .Net, not just from a database. You can try the following:
If you got a class like this
Code:
Public Class myBoundToClass
Private _SomeData As String = "DefaultValue"
Public Property SomeData() As String
Get
Return _SomeData
End Get
Set(ByVal Value As String)
_SomeData = Value
End Set
End Property
End Class
and youve got a textbox on a form, you can bind the textbox to the class above by adding the following code in the, e.g. form load event:
hey wow thats cool i might have to use that
Let me get this right... so if i have a property in one class and i want to have another property in another class mirror that property this would be what to do eh?
How would I define DataBinding property in a class that is already using inheritence?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.