How do you bind a control to a property declared in a form?


Author
Message
Charles R Hankey
Charles R Hankey
StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)
Group: Forum Members
Posts: 524, Visits: 30K
This may be the day of class I missed Tongue but is it possible to bind a textbox (or datepicker or grid or whatever ) to a property ( which perhaps is a list(of T) ) declared in the code of the form itself? i.e. no business object, just whatever is done to that control changes the value of the property without further coding.



I guess one could test on leaving a textbox or whatever and then change the property based on the text but I was thinking more of two way binding to a property. Seems the properties sheet wants a bizobj in order to bind. Should I use a non SF textbox for something like this?



Just feel I'm missing/forgetting/am completely ignorant of something very basic ... w00t





Replies
Charles R Hankey
Charles R Hankey
StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Just wanted to bump this in hope Dustin or Trent would see it. I am particularly interested in storing a number of datatables, each representing a couple of columns of data that would show up on a form which I could present in the interface as plain ol' grids that resemble the form interface. IOW I want to store each datatable as if it is a child table



My thinking was to have one big object that is a collection of these datatables. when I save I store off the datatables to items in the collection, then store the whole collection in one column in sql.



This is data that will be used for filling in PDF forms, so the number of rows is very finite. my main concern is easy data entry for the user, with columnar data flowing as they would expect - i.e. filling in an entire row before creating a new row.



Am I on the right track with this?



Any suggestions, examples whatever would be greatly appreciated



>>My thought was, if I have a collection - List(of String) let's say - stored in a SQL column. When I deserialize that list I now have a local variable that is a list of strings for that record in the BO. I want that list to be displayed on the screen in a listview, checkedlistbox or whatever. I want any changes made in that UI component to be reflected in the current contents of the list, such that when I'm done if I write that list back into the SQL column on save the changes are retained.



As I write this I"m realizing that because of the disconnected nature of the collection UI controls themselves, I am still going to have to be writing changes back to the property/variable so I guess the direct binding thing is moot for any control that is more than just a single value.



I just wanted to make sure there wasn't some magic I was missing as I want to explore the idea of wide and shallow "child" records being stored as a single serialized object in the parent record.



I'm hoping Dustin will chime in here with a little more elaboration as to how they are doing that in the medical app.
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
This is actually something that we do (kindof) in our medical application. Not in regards to binding to a form property, which can be done easily by using the standard data binding, but there is the hitch. You will need to create a bindable collection to do what you are trying to do. Here is a generic declaration in VB (leaving out the rest of the code) of the collection and implementations to basically do what you need to do.



Public MustInherit Class ChildDependent



#Region " Events "



'''

''' Occurs when a property of this object has changed.

'''


Public Event Changed As EventHandler



'''

''' Raises the Changed event.

'''


Protected Overridable Sub OnChanged()

RaiseEvent Changed(Me, EventArgs.Empty)

End Sub



#End Region



End Class




Public MustInherit Class ChildDependentCollection(Of T As {ChildDependent, New})

Inherits System.Collections.ObjectModem.Collection(Of T)

Implements IBindingList, IComponent, ITypedList



End Class




If you have never used the generic collection, it makes it very easy to create a quick collection for any class type. All of the above code is going to be slightly overkill for what you are trying to do (that is why I left all of the body of the class out). But you will need to focus on two implementations above that will allow you to natively bind to grids, etc. Start with creating a collection that exposes a simple class and implements IBindingList on the collection. Once you implement IBindingList, you will then be able to take your collection and attach it as a data source to a grid, for example, and all rows within the collection will show in the grid. Once you get a shell of this working, then you can take the next step as many lights will come on when you start this type of implementation.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search