Chan
|
|
Group: Forum Members
Posts: 533,
Visits: 2K
|
Hi,
I have an user control that contains couples of controls. I also have a linklabel in this user control that allow user to add new FK record by click on it.
Previously, I used to implement this using childformdialog and it works perfectly. However, that is done on form. How could I have childformdialog in user control also?
Please advice.
Thank you
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 7K
|
It will work the same way as when dropped on a form. Be sure to user a StrataFrame user control. This allows you to create a user control and then drop that control on a form and have the BOs translated through the BOTranslations property.
|
|
|
Chan
|
|
Group: Forum Members
Posts: 533,
Visits: 2K
|
Hi,
No, when I drop ChildFormDialog on SF user control, VS complaint its parent should be based on baseform. I still can see ChildFormDialog on control tray, but it doesn't work during runtime. And I am sure I am using SF user control because I saw BOTranslation property there.
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 7K
|
It will still work. The message indicates that it is expecting a BaseForm, but it will still work.
|
|
|
Chan
|
|
Group: Forum Members
Posts: 533,
Visits: 2K
|
Hi,
When I run project, error message as shown below prompted. I click on and continue to test my form. I will hit error. After I debug, I found that _ParentForm is always nothing.
From the code in ParentForm(), it seem like _ParentForm is not initialized because of its rootcomponent is not baseform.
Please advice
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 7K
|
I did not think this error would occur during runtime...sorry about this  But you are right. At the moment this ChildFormDialog relies on having access to a BaseForm. One option is to create the ChildFormDialog in code and manually set the properties and see if it will work for you in that capacity. But at the moment, the ChildFormDialog cannot be dropped directly on a user control. One thing you can do is use the SharedDataTableKey instead in this scenario. If you set the SharedDataTableKey on a BO to the same value on two different instances, they will share the same internal data table. This may be a solution for you in this instance.
|
|
|
Chan
|
|
Group: Forum Members
Posts: 533,
Visits: 2K
|
Hi, Thank you. I have tried your suggestion to add childformdialog to user control programmatically. It works with condition: 1. ChildFormDialog always refer to ParentForm when GetBusinessObject(). Therefore, I have to drop the same BO on my form also. This way, I have way to "encapsulate" my BO in user control. 2. ChildFormDialog.ParentForm must be set with this.ParentForm (usercontrol.ParentForm) this.CountryFormAddDialog.ParentForm = (BaseForm)this.ParentForm; Hope that is enhancement on this area in upcoming version. I will try out ShareDataTableKey approach later. Stay tuned
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 7K
|
All you have to do is set the ParentForm property of the ChildFormDialog. this.CountryAddFormDialog.ParentForm = (MicroFour.StrataFrame.UI.Windows.Forms.BaseForm)this.ParentForm; if (this.CountryAddFormDialog.ShowDialog() == DialogResult.OK) { this.cboCountry.SelectedValue = this.countriesBO.CountryID; } So I was right whe I said that you could drop the ChildFormDialog control on the user control. You just have to set the ParentForm property.
|
|
|
Chan
|
|
Group: Forum Members
Posts: 533,
Visits: 2K
|
Hi,
Thank you for clarify.
As I mentioned in my previous post, this "workaround" will still refering BO that located at ParentForm.
Any plan to enable ChildFormDialog to refer to user control so that my user control can work "independently". Once it been dropped on form, my combobox for example in user control population will works without need to remember to drop the same BO on parent form again. The only thing I need to do is set BOTranslation for data binding.
|
|
|
StrataFrame Team
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
You can do the same think with a ChildFormDialog on a UserControl as you can with a ChildFormDialog on a form. When you set the business object translations, you can translate the business object on the UserControl to the on on the child form, and if you need to, you can then add the same business object to the parent form and translate it to the one on the UserControl, but you don't have to.
|
|
|