Difference between user control and form


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Really either.  It depends on what you are trying to accomplish with the user control.  But if you add this before the MyBase.OnLoad method when overriding the OnLoad of the form, you will be fairly certain to create the translations before any translations take place.
David Daragon
David Daragon
StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)
Group: Forum Members
Posts: 54, Visits: 249
Hi Trent,

In fact, I want to use User Control to re use them in several screens. So I want to use code to create dynamicly my user controls and  I don't manage to create translations between my form and my user control.

When I put my user control in my form on the designer it works correctly.

Nevertheless, when I do the same by code by creating myself translations in the Form_Load(), it doesn't work. I put code before the InitializeComponent() and after but the result is the same.

What can I do ?

Thanks

David

Trent Taylor
Trent Taylor
StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
What can I do ?

Well, let's go at it from this perspective.  The BOs get translated within the Load of the form.  The SF users controls also have a property that exposes which object from which to translate.  I am not answering from a machine with VS on it (long story), but the user control has a property called TranslationObject (I think), but it will be iin the same category as the BOTranslations property of the UserControl.

You can set this to the form (or even set it in code) and it may resolve your problem.  If not, you can also implement the IParentFormLoading interface to control the initialization of the control.  But let's start with the first before we get into the second.

David Daragon
David Daragon
StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)
Group: Forum Members
Posts: 54, Visits: 249
Hello Trent,

Here is my code.

public partial class Form1 : MicroFour.StrataFrame.UI.Windows.Forms.StandardForm

{

private ClientBO _clientBO;

private BusinessObjectTranslationItem _BOTranslationItem1 = new BusinessObjectTranslationItem();

private ucClient _ucClient;

 

public Form1()

{

InitializeComponent();

_clientBO = new ClientBO();

_ucClient = new ucClient();

_clientBO.ParentContainer = this;

_clientBO.SynchronizingObject = this;

this.PrimaryBusinessObject = _clientBO;

this.Width = 1000;

this.Height = 750;

this.WindowState = FormWindowState.Normal;

_BOTranslationItem1.DestinationBusinessObject = "_ucClient.clientBO1";

_BOTranslationItem1.SourceBusinessObject = "Form1._clientBO";

_ucClient.BOTranslations.AddRange(new MicroFour.StrataFrame.UI.Windows.Forms.BusinessObjectTranslationItem[] {

_BOTranslationItem1});

_ucClient.Dock = System.Windows.Forms.DockStyle.Fill;

_ucClient.ParentContainer = this;

_ucClient.TranslationObject = this;

}

private void Form1_Load(object sender, EventArgs e)

{

_ucClient.Visible = true;

_ucClient.OnFermerFenetre += new EventHandler(_ucClient_OnFermerFenetre);

 this.Controls.Add(_ucClient);

}

void _ucClient_OnFermerFenetre(object sender, EventArgs e)

{

((MicroFour.StrataFrame.UI.Windows.Forms.UserControl)(sender)).ParentForm.Close();

}

}

I already set the TranslationObject property of my user control to my form. So, I will implement the IParentFormLoading interface to control the initialization of the control as you said.

David

Trent Taylor
Trent Taylor
StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
I really think that something is missing.  I don't think that the IParentFormLoading event will be your solution from looking at your code.  We are in the field training again this week, so our time is a bit limited.  However, instead of going back and forth, just create a simple sample and then we will take a look instead of going back and forth via the forum.
David Daragon
David Daragon
StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)
Group: Forum Members
Posts: 54, Visits: 249
Hi Trent,

I send you a sample project. I put the 2 examples. One with my user control created directly on the form by the designer which works. The other in which I create the user control and BOTranslation in the code.

David

David Daragon
David Daragon
StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)
Group: Forum Members
Posts: 54, Visits: 249
Hi

Did you have the time to test my sample ?

Regards,

David

Trent Taylor
Trent Taylor
StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)StrataFrame Developer (8.5K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
I will take a look at this soon, but we have just gotten back from being on the road and have a lot going on and we also have a lot of people out on vacation, so we are still trying to catch up.  Thank you for being patient.
David Daragon
David Daragon
StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)
Group: Forum Members
Posts: 54, Visits: 249
No worry Trent I just want to know to organize my work.

I will work with Strataframe for many years so I have time BigGrin

David Daragon
David Daragon
StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)StrataFrame Novice (54 reputation)
Group: Forum Members
Posts: 54, Visits: 249
no issue at my problem ?
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