Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programmatically set anchorstyles on user control

Status
Not open for further replies.

moongirl129

Programmer
Sep 5, 2002
38
GB
I am programmatically adding a tabpage to a tabcontrol, and then adding a user control to this tab page. The application starts maximized and I need to make sure that this user control stretches to fill the tab page by setting it's anchorstyles. However my code just doesn't seem to be having any effect on the anchor styles at all and I wondered if anyone knew why?

Code:
departmentTabControl.TabPages.Add("Dept " + dept.Name);

                        DeptIssueControl depIssueControl = new DeptIssueControl();
                        depIssueControl.PeopleIssues = dept.PeopleIssues;
                        depIssueControl.PremisesIssues = dept.PremisesIssues;
                        depIssueControl.ProprietyIssues = dept.ProprietyIssues;

                        departmentTabControl.TabPages[count].Controls.Add(depIssueControl);
                        
                        depIssueControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));

Incidentallty I have tried setting the dock property to Fill and this works fine but in this case is not quite the effect I'm after. Any thoughts appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top