Question

I have design a form which contains one tab control and dynamically adding tab pages. Problem: in each tab page, controls are not placed at correct place as given "LOcation" field while adding "Anchor property to RIGHT OR BOTTOM or eighter of it. If i remove anchor then it works fine. But i need to use anchor to resolve resize of form should remain consistent for the controls.

Please suggest how i could resolve this issue and also anchor should remain there.

Below is the code:

        Dim t As TabPage = New TabPage(titletext)
        t.Name = IDValue
        Dim w As New WebBrowser()
        Dim b As New Button()
        b.Text = "&Close"
        w.Size = New Size(New Point(tcrViewer.Width - 3, tcrViewer.Height - (b.Height + 30)))
        w.Anchor = AnchorStyles.Right Or AnchorStyles.Bottom            
        w.Location = New Point(0, 0)
        w.Navigate(url)
        t.Controls.Add(w)

        b.Location = New Point(w.Width - (b.Width + 30), w.Size.Height + 3)
        b.Anchor = AnchorStyles.Bottom Or AnchorStyles.Right
        AddHandler b.Click, AddressOf btnReportClose_Click
        t.Controls.Add(b)
        tcrViewer.TabPages.Add(t)
        tcrViewer.SelectedTab = t
        tcrViewer.SelectedTab.Focus()

when execute the form, then, WEBEXPLORER CONTROL CUTS by form and it does not appear on "0,0" location and same thing happen for Button also. If i remove "Anchor" then its all fine as follow the location.

Please resolve

Thanks

Was it helpful?

Solution

The issue is resolved.

I have removed "DocK" property and added webexplorer into the panel.

Anchor is applied to "Bottom" and "Right" only and not to top, left. Then its work fine for Bottom,right anchor style.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top