C# – Is an event thrown when a custom control gets its final size? (.NET Compact Framework)

ccompact-frameworkcustom-controlswinforms

I'm developing a Windows Mobile 5.0 or above with .Net Compact Framework 2.0 SP2 and C#.

I have a custom control called PullDownMenu (it inherits from System.Windows.Form.Control). This is the code that I use on a WinForm to show it:

PullDownMenu menu = new PullDownMenu();
menu.Location = new Point(0, 0);
menu.Dock = DockStyle.Fill;
this.Controls.Add(menu);

I've noticed that it size changes during this process. How can I know when it gets its final size?

Yes, I know I can check OnResize event but this event it is called several times and I think it can downgrade the performance.

Is there an event that is thrown when the control is completely displayed? or when it is added to its parent (on this line: this.Controls.Add(menu);).

Any advice?

Best Answer

Some of the controls in the Compact Framework support BeginUpdate and EndUpdate methods which may help this issue. Using a custom control, I believe that you may have to implement your own methods to support this behavior.

To improve rendering performance, call the BeginUpdate, update the properties that may change its size, and then call the EndUpdate method. This will minimize the render calls that are invoked by the resizing.