moongirl129
Programmer
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?
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.
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.