Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
| Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 13th, 2007, 10:24 AM
Authorized User
 
Join Date: Feb 2007
Location: , , USA.
Posts: 37
Thanks: 1
Thanked 0 Times in 0 Posts
Default WinForm Resizing instantiated form inside Tab Page

Hi,
     I have Tab Page inside Mainform.I have loaded another Form's instance inside Tab Page.I am setting form's instance width initially while it loads inside Tab page which sets it perfectly.Now when my mainform's Resize event fires it resize all other controls on main form properly(location and width of control according to form size) but it does not setting width of Instantiated form inside Tab page when i am setting its widhth with the width of Mainform(or Tabpage).I tried to put explicit width of form's instance but that even did not change its width. Any one has idea for Instantiated form width can be changed at runtime....

Thanks,
Maulik
 
Old June 13th, 2007, 11:51 AM
Authorized User
 
Join Date: Nov 2006
Location: Valparaiso, IN, USA.
Posts: 93
Thanks: 0
Thanked 1 Time in 1 Post
Default

maulik33,

Try adding a public method to your inserted form that handles the resizing of the inserted form. Then call that method when you resize your control tab.

good luck

What you don't know can hurt you!
 
Old June 13th, 2007, 12:40 PM
Authorized User
 
Join Date: Feb 2007
Location: , , USA.
Posts: 37
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks for reply. I tried that way but i did not resized form . if i open Instantiated Form Separately(not in tab but as regular form opening) than it resizing properly.

 
Old June 13th, 2007, 12:57 PM
Authorized User
 
Join Date: Nov 2006
Location: Valparaiso, IN, USA.
Posts: 93
Thanks: 0
Thanked 1 Time in 1 Post
Default

I tried this and it worked.

I set up 2 projects in the same namespace (don't think the namespace matters though). The first project is a class library that contains a form (Form1). The second is a Windows Application with a form that contains a Tab control (FormTab). Here are excerpts of code from the projects:

Form1:
namespace InsideForm
{
  public partial class Form1 : Form
  {
    public Form1()
    {
      InitializeComponent();
      this.SetTopLevel(false);
    }

    public void ResetSize(System.Drawing.Size NewSize)
    {
      this.Width = NewSize.Width;
      this.Height = NewSize.Height;
    }
  }
}

You see the "ResetSize" public method. It will be called by "FormTab" when it is resized.

FormTab:
namespace InsideForm
{
  partial class FormTab
  {
    private InsideForm.Form1 MyForm;
...
    private void InitializeComponent()
    {
...
      this.MyForm = new Form1();
      this.MyForm.Location = new System.Drawing.Point(5, 5);
      this.MyForm.Size = new System.Drawing.Size(391, 296);
      this.MyForm.Name = "MyForm";
      this.MyForm.Visible = true;
      this.MyForm.Enabled = true;
...
      this.tabPage1.Controls.Add(this.MyForm);
...
      this.Resize += new System.EventHandler(FormTab_Resize);
      this.tabControl1.ResumeLayout(false);
      this.ResumeLayout(false);
    }

    void FormTab_Resize(object sender, System.EventArgs e)
    {
      tabControl1.Width = this.Width - 22;
      tabControl1.Height = this.Height - 48;
      MyForm.ResetSize(new System.Drawing.Size(tabControl1.Width - 10, tabControl1.Height - 10));
    }
...
  }
}

I'm not sure why this is not working for you.


What you don't know can hurt you!
 
Old June 13th, 2007, 01:48 PM
Authorized User
 
Join Date: Feb 2007
Location: , , USA.
Posts: 37
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks david. Your code looks straight forward but still my form size is not increasing. this form has been inherited one already and i am creating instance to load inside Tab page. form width seems protected by base form some how but you gave me good hint.my Main form and instance form are in diffrent namepsace though but as you said that does not matter. I will work on it and if make it post it to you...

Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Open Existing Winform inside Tab Page maulik33 C# 2 May 24th, 2007 10:05 AM
resizing the contentplaceholder in the master page ersdhivya ASP.NET 2.0 Basics 1 October 31st, 2006 09:26 AM
Multi-Tab form srotondo Classic ASP Professional 1 April 27th, 2006 06:38 PM
Resizing form dotnetprogrammer VS.NET 2002/2003 0 February 23rd, 2005 02:58 AM
Resizing of form view - problem lmadhavi Visual C++ 2 October 1st, 2004 06:18 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.