Click here to Skip to main content
15,888,351 members
Home / Discussions / C#
   

C#

 
AnswerRe: XML Mapping to CSV Pin
PIEBALDconsult3-Jan-13 14:07
mvePIEBALDconsult3-Jan-13 14:07 
GeneralRe: XML Mapping to CSV Pin
RickSharp4-Jan-13 6:05
RickSharp4-Jan-13 6:05 
GeneralRe: XML Mapping to CSV Pin
PIEBALDconsult4-Jan-13 10:46
mvePIEBALDconsult4-Jan-13 10:46 
GeneralRe: XML Mapping to CSV Pin
RickSharp4-Jan-13 13:22
RickSharp4-Jan-13 13:22 
GeneralRe: XML Mapping to CSV Pin
jschell4-Jan-13 14:12
jschell4-Jan-13 14:12 
AnswerRe: XML Mapping to CSV Pin
jschell4-Jan-13 14:11
jschell4-Jan-13 14:11 
Questionhow to setup that form in the tabpage when tabpage resized Pin
linuxaidtest3-Jan-13 3:47
linuxaidtest3-Jan-13 3:47 
AnswerRe: how to setup that form in the tabpage when tabpage resized Pin
BillWoodruff3-Jan-13 16:42
professionalBillWoodruff3-Jan-13 16:42 
Well, you can achieve this, and here's an example:
public partial class Form1 : Form
{
    public Form1(){ InitializeComponent();}

    private Form form2 = new Form();
    private Panel pnl1 = new Panel();
    private Button btn1 = new Button();
    private TabPage tbPg1 = new TabPage();

    private void Form1_Load(object sender, EventArgs e)
    {
        pnl1.BackColor = Color.SlateBlue;
        pnl1.Padding = new Padding(32);

        form2.TopLevel = false;
        form2.FormBorderStyle = FormBorderStyle.FixedSingle;
        form2.ControlBox = false;
        form2.MaximizeBox = false;
        form2.MinimizeBox = false;
        form2.Text = "";
        form2.BackColor = Color.Azure

        form2.Resize += (ob, ea) =>
        {
            btn1.Location = new Point((form2.Width/2) -(btn1.Width/2),
            (form2.Height/2) - (btn1.Height/2));
        };

        form2.Parent = pnl1;
        form2.Dock = DockStyle.Fill;
        form2.Visible = true;

        btn1.AutoSize = true;
        btn1.BackColor = Color.WhiteSmoke;
        btn1.Text = "button on the Form";

        form2.Controls.Add(btn1);
        btn1.Click += (ob, ea) => { MessageBox.Show("Button on Form Clicked"); };

        tbPg1.BackColor = Color.LightSteelBlue;
        tbPg1.Text = "Test Form in Panel in TabPage";
        tbPg1.Padding = new Padding(32);

        tbPg1.Controls.Add(pnl1);
        pnl1.Dock = DockStyle.Fill;

        tabControl1.Controls.Add(tbPg1);
    }
}
But, I wonder: why are you inserting a Form in a Panel which is then inserted in a TabPage ?

In general, you should not be using a Form inside any other Container Control, including another Form: Forms are "heavy-weight" .NET objects, and really are not meant to be used this way.

Yes, .NET WinForms will let you "get away with it," but that does not mean it is good practice. If you really need to design the contents of TabPages in their own designer, outside of the TabControl itself, why not use a UserControl, a "lighter-weight" object ?

To change from using a Form, to using a UserControl in the above example, is as simple as making these changes to the code:

     1. private UserControl form2 = new UserControl();
         ... of course, being a good programmer, you will change form2's name to something more mnemonic !

     2. comment out the following four lines in the Form_Load EventHandler, like this:

     //form2.FormBorderStyle = FormBorderStyle.FixedSingle;
     //form2.ControlBox = false;
     //form2.MaximizeBox = false;
     //form2.MinimizeBox = false;

If you share something about your design goals here, I'd be happy to respond with suggestions, and I am sure that other CP Members will also respond.

yrs, Bill
QuestionReading Excel from different processes in different computer Pin
SaneLucky3-Jan-13 2:58
SaneLucky3-Jan-13 2:58 
AnswerRe: Reading Excel from different processes in different computer Pin
Super Lloyd3-Jan-13 17:55
Super Lloyd3-Jan-13 17:55 
AnswerRe: Reading Excel from different processes in different computer Pin
April Fans3-Jan-13 19:33
April Fans3-Jan-13 19:33 
AnswerRe: Reading Excel from different processes in different computer Pin
micke.andersson28-Jan-13 4:45
micke.andersson28-Jan-13 4:45 
QuestionKeyValuePair from reference dll Pin
Isaksson3-Jan-13 1:52
Isaksson3-Jan-13 1:52 
AnswerRe: KeyValuePair from reference dll Pin
Super Lloyd3-Jan-13 17:51
Super Lloyd3-Jan-13 17:51 
GeneralRe: KeyValuePair from reference dll Pin
Isaksson3-Jan-13 21:14
Isaksson3-Jan-13 21:14 
GeneralRe: KeyValuePair from reference dll Pin
Super Lloyd3-Jan-13 22:48
Super Lloyd3-Jan-13 22:48 
GeneralRe: KeyValuePair from reference dll Pin
Isaksson4-Jan-13 0:41
Isaksson4-Jan-13 0:41 
Questionhow to connect and disconnect to internet by Exist connection Pin
apadana_19892-Jan-13 17:44
apadana_19892-Jan-13 17:44 
QuestionRe: how to connect and disconnect to internet by Exist connection Pin
Richard MacCutchan2-Jan-13 22:15
mveRichard MacCutchan2-Jan-13 22:15 
AnswerRe: how to connect and disconnect to internet by Exist connection Pin
jschell3-Jan-13 8:11
jschell3-Jan-13 8:11 
QuestionHow to create a colletion of properties in a C# class Pin
bnath0012-Jan-13 12:59
bnath0012-Jan-13 12:59 
AnswerRe: How to create a colletion of properties in a C# class Pin
PIEBALDconsult2-Jan-13 13:34
mvePIEBALDconsult2-Jan-13 13:34 
AnswerRe: How to create a colletion of properties in a C# class Pin
Abhinav S2-Jan-13 15:42
Abhinav S2-Jan-13 15:42 
AnswerRe: How to create a colletion of properties in a C# class Pin
OriginalGriff2-Jan-13 21:16
mveOriginalGriff2-Jan-13 21:16 
GeneralRe: How to create a colletion of properties in a C# class Pin
bnath0013-Jan-13 5:59
bnath0013-Jan-13 5:59 

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.