| Author |
Share Topic Topic Search Topic Options
|
GregD
IdeaBlade
Joined: 09-May-2007
Posts: 374
|
Post Options
Quote Reply
Topic: Many-to-Many object mapping questions Posted: 20-Aug-2007 at 3:50pm |
Oh, now I see what you want.
I'd probably create a UserControl to display the properties of an Insured in loose controls. You could then embed that on a Policy form (or tab page, etc.). As you move from one Policy to the next, the Policy form could push an EntityList of Insureds down to the InsuredUserControl. Then you could use a BindingNavigator or the like on the InsuredUserControl to move among the Insureds for a given Policy. You'd see one at a time, just like you see Employees in our tutorial apps.
You might want to have a look at the "Composing Forms with UserControls" instructional unit in the 200 Intermediate series to see an example of pushing data around like I just described. In those examples we're still displaying the many children in a grid, but that's just a detail: the children will display just as well, one at a time, in bound loose controls.
|
 |
cporter
Newbie
Joined: 15-Aug-2007
Location: United States
Posts: 4
|
Post Options
Quote Reply
Posted: 20-Aug-2007 at 2:21pm |
|
Instance may be a good term, but what I am really talking about is similar to your example where Customers have orders. Orders are always shown in grids, not in loose controls.
A hard example may illustrate it better. On a display form, I show one policy. This policy has 2 Insureds. In relation to Policy via PolicyInsured, one of these is a Primary insured (in the case of this policy), and the other is a secondary. I have 2 frames that have identical loose controls. I want to populate the first frame's controls with the Primary insured's data.
All of the ideablade examples would put the Insureds in a grid. There would be a direct correlation with datarows and grid rows.
|
 |
GregD
IdeaBlade
Joined: 09-May-2007
Posts: 374
|
Post Options
Quote Reply
Posted: 20-Aug-2007 at 10:06am |
Sorry, Clay, I'm still not understanding where our disconnect is. The ControlBindingManager is for binding to loose controls, like TextBoxes, DatePickers, etc. -- *not* grid controls. Use of the ControlBindingManager is well illustrated in the tutorials.
When you use the term "member" of a class, are you speaking of properties, methods, etc., or are you referring to "instances" of a class? I'm not quite clear what you're trying to do.
Greg Dunn
|
 |
cporter
Newbie
Joined: 15-Aug-2007
Location: United States
Posts: 4
|
Post Options
Quote Reply
Posted: 20-Aug-2007 at 7:42am |
|
I did review the tutorials, and could not find exactly what I am looking for. I want to map collection class members to controls *other than a grid*.
When there is more than one member of the class, I want to show specific members in non-grid controls based on a value attached to the member (Primary/Secondary).
I did figure out a way to do it in code; I had hoped that there would be a way to use the controlBindingManager to do it. But it doesn't appear to me to be possible. So I create a bindingSource for each member I want to display and then use AddBinding. It works, and that is what matters. Thanks
|
 |
GregD
IdeaBlade
Joined: 09-May-2007
Posts: 374
|
Post Options
Quote Reply
Posted: 16-Aug-2007 at 1:21pm |
Clay:
Use the DevForce ControlBindingManager for loose controls. This is illustrated in the basic tutorial sequence, in the "Populating a Winform" instructional unit.
Greg Dunn
IdeaBlade
|
 |
cporter
Newbie
Joined: 15-Aug-2007
Location: United States
Posts: 4
|
Post Options
Quote Reply
Posted: 16-Aug-2007 at 6:21am |
|
Thanks! It works, just as you describe.
Another question - The specs call for the insureds to be displayed in non-grid controls, i.e., a frame with text boxes for Primary and another for Secondary. Can you explain how I can bind the class members to controls vs a grid? I know I can get there by hand using generics/Find but that appears to me to defeat the purpose of having databinding. I am attempting to use the Databindings.Add() but not having much success.
I apologize for asking such elementary questions. I have dug through all the IdeaBlade documentation and forums, and haven't seen a clear example of anything but a grid. Maybe there aren't many real world apps that use anything but a grid(?)
Thanks again.
|
 |
GregD
IdeaBlade
Joined: 09-May-2007
Posts: 374
|
Post Options
Quote Reply
Posted: 15-Aug-2007 at 4:11pm |
Clay:
Not sure what you mean by "carry through to the attached collection".
You could easily populate a grid of augmented PolicyInsured objects whose rows would include cells not only for all of the properties that correspond directly to columns in the PolicyInsured table, but also for any desired properties of the PolicyInsured's related Insured and/or Policy object. I.e., the table could have cells for any or all of the following (as examples):
PolicyInsured.Id
PolicyInsured.InsuredTypeCode
PolicyInsured.Policy.PolicyNumber
PolicyInsured.Insured.LastName
PolicyInsured.Insured.SocialSecurityNumber
and so forth. Only the PolicyInsured object has a one-to-one relation to Policy and Insured; so it is only from that object that you can directly drill into the property lists of Policy and Insured.
Let me know if I'm not understanding your question.
Greg Dunn
IdeaBlade
|
 |
cporter
Newbie
Joined: 15-Aug-2007
Location: United States
Posts: 4
|
Post Options
Quote Reply
Posted: 15-Aug-2007 at 8:44am |
|
I have a MtM relationship that has a field in the join table that needs to carry through to the attached collection. I used the optimized query method to populate the data class for the second table, but I don't quickly see a way to obtain the value of the field in the intermediate table.
First table (Policy) has PolicyID etc Second table (Insured) has InsuredID etc join table (PolicyInsured) has PolicyID,InsuredID, and InsuredTypeCode.
I need the Insured members to have an InsuredTypeCode to carry through from the join table.
Many policies have many insureds. An insured may be a primary in one policy, but secondary in another.
Thank you for any help!
|
 |