My problem:
I'm creating a new instance of a Form containing a Ribbon control:
Form2 newForm = new Form2();
I'm then setting the Top, Left, Width and Height properties for the form:
newForm.Location = new Point(layout.Left, layout.Top);
newForm.Size = new Size(layout.Width, layout.Height);
I then show the form:
newForm.Show();
The issue is that the form, when it appears, is NOT the height and width I've set through the Size property. It's smaller.
When I close the form, I save the current Location and Size. When I run through this process again, the form opens up ... and it's smaller again than last time.
It seems as though the process of "Show"ing the form is causing the Ribbon to react and resize the form.
What I need is for all of the Ribbon drawing actions etc to take place BEFORE I set the size of the form. I thought that would happen with the "new"ing of the form, but it's not.
I can't set the size of the form after calling "Show", because then there's visible movement of the form, ie. the user sees the form open at one size, and then change size to the new size.
How can I fix this? Is there an event or something related to the Ribbon doing it's form drawing, that has an "After" or "Completed" process in which I can force my form size?
Sample project demonstrating the problem attached.
Thanks!
T
Hi,
Thank you for posting in our forums with the attached sample.
What you could do in order to fix this is to set the form size, in the form’s Load event instead of when you are initializing it. This way the form will have the size that you have set.
I have modified your sample in order to demonstrate this approach.
Please let me know if you have any additional questions.
Hi Dimitar,
Thanks for your reply.
It's still not quite perfect ... there's a slight lag between when the form is drawn, and when the form resizes. It's not easy to demonstrate ... I've abstracted the problem based on code from a much larger application that has multiple levels of visual inheritance in forms etc. However, I don't think there's much that can be done about those delays ... they're simply a result of the application itself being so big and complex.
Your solution has improved things though, so thanks!