Difference between user control and form


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

I'm still making tests.

I put a list view in a Micro Four User Control which is contained in a Micro Four Form and the time of loading is 2800 ms.

When I put directly the same list in a Micro Four Form, the time is about 450 ms.

What are the reasons of this difference ?

Best regards

David

Replies
David Daragon
David Daragon
StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)
Group: Forum Members
Posts: 54, Visits: 249
Just one more thing, there is an error in my code.

The line "_ucClient.BOTranslations.Add(_BOTranslationItem1);" isn't not in my code.

David

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
David,

First, I think that you are making this harder than you need to in regards to the user control.  Just for a little background, we have a large number of user controls that are used within dialogs and forms which in turn use the BO translations between the two.  Here is how a user control is intended to work:

  1. Drop your BOs on a user control and bind to them just as though they were on a form
  2. Once the user control is written, drop that user control on a form or dialog
  3. Drop on the BOs of the same type that were dropped on the user control
  4. Then build the project
  5. Stay within the designer, and select the user control
  6. Go the BO Translations of the user control and click the "..." button
  7. This will then bring up a translations dialog.  Add a translation for each BO that needs to be translated from the dialog into the user control...they will have to be of the same BO type on each translation (one for one).
  8. Now populate the BOs on the form (or the user control can populate them if this is how you intend your app to work, but just for arguments sake, lets populate the Bos on the dialog here)
  9. Now when you run, you should be able to populate the BOs on the form and you will see them reflected within the user control

David Daragon
David Daragon
StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)
Group: Forum Members
Posts: 54, Visits: 249
Thanks for your help Trent,

I follow your method and it's work.

But if I want to do the same by code and not by the designer, I don't manage to laod my list.

Do I forget something in the code I posted before ?

David

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Gotcha....yes, you can do this in code, but you will have to do it in the OnLoad prior to the MyBase.OnLoad gets called so that the translations take place in the natural or expected order.  This is actually something that we do a bit ourselves.
David Daragon
David Daragon
StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)
Group: Forum Members
Posts: 54, Visits: 249
In which OnLoad ? In the form or in the user control ?
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
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 (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 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 (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
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 (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 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 (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
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 (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 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 (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 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 (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
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 (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 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 (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 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...




Threaded View
Threaded View
David Daragon - 17 Years Ago
Trent L. Taylor - 17 Years Ago
David Daragon - 17 Years Ago
David Daragon - 17 Years Ago
David Daragon - 17 Years Ago
                         Just one more thing, there is an error in my code. The line...
David Daragon - 17 Years Ago
                             David, First, I think that you are making this harder than you need...
Trent L. Taylor - 17 Years Ago
                                 Thanks for your help Trent, I follow your method and it's work. But...
David Daragon - 17 Years Ago
                                     Gotcha....yes, you can do this in code, but you will have to do it in...
Trent L. Taylor - 17 Years Ago
                                         In which OnLoad ? In the form or in the user control ?
David Daragon - 17 Years Ago
                                             Really either. It depends on what you are trying to accomplish with...
Trent L. Taylor - 17 Years Ago
                                                 Hi Trent, In fact, I want to use User Control to re use them in...
David Daragon - 17 Years Ago
                                                     [quote]What can I do ?[/quote] Well, let's go at it from this...
Trent L. Taylor - 17 Years Ago
                                                         Hello Trent, Here is my code. [codesnippet] public partial...
David Daragon - 17 Years Ago
                                                             I really think that something is missing. I don't think that the...
Trent L. Taylor - 17 Years Ago
                                                                 Hi Trent, I send you a sample project. I put the 2 examples. One with...
David Daragon - 17 Years Ago
                                                                     Hi Did you have the time to test my sample ? Regards, David
David Daragon - 17 Years Ago
                                                                         I will take a look at this soon, but we have just gotten back from...
Trent L. Taylor - 17 Years Ago
                                                                             No worry Trent I just want to know to organize my work. I will work...
David Daragon - 17 Years Ago
                                                                             no issue at my problem ?
David Daragon - 17 Years Ago
Dustin Taylor - 17 Years Ago
David Daragon - 17 Years Ago
                 It would be better with the attachment :D ;)
David Daragon - 17 Years Ago
Trent L. Taylor - 17 Years Ago
                         Hi I succeed to load a listview in an user control with a designer....
David Daragon - 17 Years Ago
                             If I understand you correctly, you want to programatically add your...
Greg McGuffey - 17 Years Ago
                                 You're right Greg. I want to programatically add an user control in my...
David Daragon - 17 Years Ago
                                     David,

I see a couple of things that don't make sense:...
Greg McGuffey - 17 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search