Sazlo Posted December 5, 2005 Posted December 5, 2005 Say i am binding to an ArrayList. The ArrayList contains a group of ObjectA's defined, loosely, as the following: public class ObjectA { private ObjectB objB; public ObjectB ContainedObject { get{return objB;} } } Is it possible to bind to a property of Object B? Ive tried using a binding string of "ContainedObject.SomeProperty" but obviously that doesnt work. Any thoughts? Saz Quote
Cags Posted December 5, 2005 Posted December 5, 2005 If you wish to return a property of a child object you can do something like the following, basically you just make a property of the type of the childs property... public class ObjectA { public string Name { get { return "Object A"; } } } public class ObjectB { private ObjectA objA = new ObjectA(); public string ObjAName { get { return objA.Name; } } } Does this answer your question? Quote Anybody looking for a graduate programmer (Midlands, England)?
Sazlo Posted December 5, 2005 Author Posted December 5, 2005 Aye, thats what I've been doing as a work around. However, Id rather not take that approach if its possible. I find it a tad clunky since those exposed properties contain data that doesnt really apply to the object exposing them. Ive thought along the lines of creating a "helperobject" to contain the necessary information for binding(including child object data) and have the parent create it when needed. I could achieve the same effect and keep the information logically seperated for processing. The helperobject would be a read only snapshot and strictly used for databinding. Perhaps thats a good way to go. Any more input is greatly appreciated. Thanks, Saz Quote
barski Posted December 6, 2005 Posted December 6, 2005 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/html/winforms02182005.asp Quote
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.