dubem1 Posted February 28, 2003 Posted February 28, 2003 Hello! 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 don't know how. Can someone helps and/or provide an example please Thanks a lot!!!! Martin Quote
bpayne111 Posted March 1, 2003 Posted March 1, 2003 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 i hope that helps Quote i'm not lazy i'm just resting before i get tired.
Cywizz Posted March 3, 2003 Posted March 3, 2003 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 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 you've 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: TextBox1.DataBindings.Add("Text", _myBoundClass, "SomeData") where _myBoundClass refers to a instance of the above class. Hope it helps Cheers! Quote Howzit??
bpayne111 Posted March 3, 2003 Posted March 3, 2003 hey wow that's 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? Quote i'm not lazy i'm just resting before i get tired.
Cywizz Posted March 3, 2003 Posted March 3, 2003 Databinding only available on a class that inherited from Control msdn: Binding Class: Represents the simple binding between the property value of an object and the property value of a control. Check out documentation on the Binding Class for more info... Quote Howzit??
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.