Embedding a Form in a Form |
Created Date: 4/23/2008 |
Last Modified Date: 4/23/2008 |
Sometimes in code a developer needs to embed a form within a form. This can be useful for many cases such as plugins. The concept is rather simple. First, any border would have to be set to none on the form that will be the child form. Next, the TopMost property for the form needs to be set to false. This will cause the form to not have a window hook to the screen. This code can be simply done as the following code:
C# public void AddForm(Form childform) { childform.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; child.TopMost = false; this.Controls.Add(child); } VB.Net public sub AddForm(childform As Form) { childform.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None child.TopMost = false this.Controls.Add(child) } |
:: Better Coding Practices :: |