BOTranslation, ChildForm and UserControl


Author
Message
Chan
Chan
Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

I have created an user control which contains of a linklabel BO and combobox. Combobox would show records exist in BO using CopyDataFrom method.

I placed this user control on a maintenance form. I also placed the BO required on the form and add it to BOTranslations. I called myBO.FillAll() in Form_Load, and called a UserControl.method() to requery combobox. I can see all records shown in combobox (let say 100 records).

All the above are fine, except the following. I have code to show childform to add new record when user click on linklabel. My code will call BO.Add() and ChildFormDialog.ShowDialog(). During debugging, I found that, BO.Count in usercontrol is in adding state (Count = 101) but the Form.BO.Count is not (count is still 100). It caused my childform didnt enable boundcontrol and only show the first record.

Any ideas?

Thank you

Chan
Chan
Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

For more info, the linklabel control in thus user control is a custom control inherited MicroFour's linklabel. The linklabel has property which stored a reference of BO. I have assign usercontrol.BO to this property.

After some investigation, I suspect usercontrol.BO is translated, but not the refereence of the BO assigned to linklabel property.

Any ideas?

Thank you

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
When the BOTranslations are used for both ChildFormDialogs and UserControls, sometimes, the translations between the child form and the user control happen before the translations between the parent form and the child form.  What you want is the parent form's BO to be the BO for all of the forms/controls, however if the parent->child translation doesn't happen first, then the child->user controls translation won't happen properly.

I cases like this, I would recommend using the SharedDataTableKey property.  The SharedDataTableKey property tells instances of business objects to use the same internal DataTable between all of them (same object reference).  So, you add a record to one, you're adding the record to all of them and so forth).  The only thing that isn't preserved (I think) is the EditingState between the business objects, so Add() the record on the object where you want it.  With the SharedDataTableKey, you don't have to use the BOTranslations at all, so clear them out before using the SharedDataTableKey property.

Just set the property to the some string value... doesn't matter what it is, as long as it's the same for all of the business objects that should share the table.

Chan
Chan
Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

How could I use your suggested approach to create common use control?

The custom linklabel will be used in many places for different BO and childform.

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Chan,

As Ben mentioned in his previous post, using the SharedDataTable key would probably be a good approach for you here.  It would just be a matter of creating a link label that either accepts a BusinessLayer object and possibly a SharedDataTable key property if this is going to change from time to time.  By setting these properties on your control and knowing your constraints, you could create a common control to take advantage of the data sharing very easily.

I really don't know how to expand past that without knowing all of your needs and contraints, but I would start by creating an inherited LinkLabel and then adding the BO and SharedDataTableKey properties to your control to take advantage of this approach.  In the constructor of the control, when not in design mode, you could then assign the SharedDataTableKey to the attached BO and programmatically set the binding values.

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