Click here to Skip to main content
13,147,182 members (30,312 online)
Click here to Skip to main content
Add your own
alternative version


7 bookmarked
Posted 29 Aug 2012

Use Form as Subform

, 29 Aug 2012
Rate this:
Please Sign up or sign in to vote.
This is an alternative for "Use form as subform"


This is a shortcut to the original trick from Antonio Lopez R: Use form as subform


I highly recommend that you read Antonio's article and understand it. I love embed common functions into extensions, because the code becomes very easy to read.

At first, I'll try this way:

static class SubFormExtensions
    internal static bool AttachTo(this Form subForm, Panel panel)
        if (panel == null || subForm == null) return false;
        subForm.FormBorderStyle = FormBorderStyle.None;
        subForm.TopLevel = false;
        subForm.ShowInTaskbar = false;
        subForm.Dock = DockStyle.Fill;

Using the Code

What I'm doing here is just using extensions to make things clear. Using the same example as Antonio, you can call this way:

var SubForm = new frmReportsAndCharts();

Points of Interest

This is my first test writing an article, so feel free to point anything strange here.


2012-06-12: First version of article.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior) ThyssenKrupp Industrial Solutions
Brazil Brazil
I'm just another ordinary programmer.

You may also be interested in...


Comments and Discussions

GeneralMy vote of 4 Pin
Christian Amado29-Aug-12 10:53
memberChristian Amado29-Aug-12 10:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170915.1 | Last Updated 29 Aug 2012
Article Copyright 2012 by Carlos1907
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid