Tab control "anchor"

  • Thread starter Thread starter A.C. Jetter
  • Start date Start date
A

A.C. Jetter

I am using C# in Visual Studio.Net to create an
application. The problem I
am having is when the main form is moved around on the
screen, the "panel"
form that is displayed on the tab control does not move
with the main form.
How can I "anchor" them so they move together? I do not
want to put the
panels directly on the tab control, as I want to keep
them separate to allow
a more modular approach.

I have tried to make a main form that is a MdiContainer
(attempting to force
them to stay together), but have been unsuccessful at
making the "panel"
form show on top of the tab control. The MdiParent for
the "panel" form is
being set to the correct form, but when I use "Show"
and "BringToFront" on
the "panel" form, it gives me an error... " Cannot create
a child list for
field Contact." I am unable to locate where
the "Contact" field is that the
error is indicating. The tab control has a
ContactsTabPage, and displays
"Contacts" on the tab, but all fields have a different
naming convention so
a one word field like this does not exist. I am not
using menus in the
application in order to simplify the approach and would
like to stay with
the tab control.
 
Hi,

Thanks for posting in this group.
Based on my understanding, you create a normal form whose parent form is
tabcontrol, and so you call it "panel" form.
But I can not reproduce your problem, I wrote a sample like this, set the
AnchorStyles for both the tabcontrol and the "panel" form.

private void Form1_Load(object sender, System.EventArgs e)
{
Form f=new Form();
f.TopLevel=false;
f.Parent=tabPage1;
f.Size=new Size(100,100);

f.Anchor=AnchorStyles.Bottom|AnchorStyles.Left|AnchorStyles.Right|AnchorStyl
es.Top;
f.Show();

tabControl1.Anchor=AnchorStyles.Bottom|AnchorStyles.Left|AnchorStyles.Right|
AnchorStyles.Top;

}

If I misunderstand you, please feel free to tell me.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Using Visual Studio.Net and C#: I have created a layered
window with a
form(form1) that is anchored to a tab page of a tab
control. Form1 has one
panel with various controls on about one half of the
screen, and three group
boxes on the other side. It displays properly when not
anchored to the tab
page, however when the anchoring is added, the sizing
changes and form1 is
too wide to fit on the tab page client area. I have
added a form1.Size
assigning the form1 to the size that it should be,
however it has no effect.
When I reduce assignment to the form1.Size, the right
portion of the form1
is not visible. Vertical space does not appear to be a
problem. How do I
get the form1 to display properly when anchored to the
tab page?

The problem seems to be connected not to the form1.Anchor
but when the
form1.Parent is assigned. The form1.Dock works the same
way in that the
form1 becomes too large for the client rectangle.
 
Hi,

Based on my understanding, your layer form is too big, you want to change
it size, so that it can be fully shown in the tabpage. But the Form.size
setting does not take effect.
But I still can not reproduce your problem, in my original post, I also set
the form size, also set it anchor property. But it works well.
Can you explain your problem more clearly? Or you can provide a code
snippet to reproduce this problem.
If I misunderstand you , please feel free to tell me.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top