Having Alignment Troubles with Panel1.Controls.Add(browser) .
And 3 controls in all .
When a webpage is displayed (skewed) about 50px below the top
and 20px to the right of where it should be .
How can I fix this ?
I have both a .vb & .cs version . Both have the same issue .
Below is Form1.vb followed by Form1.Design.vb .
Thanks for your Help...
Form1.vb
- Code: Select all
Imports cef
Imports CefSharp
Imports CefSharp.WinForms
Imports System.Windows.Forms
Public Class Form1
Private WithEvents browser As ChromiumWebBrowser
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim setting As New CefSettings
' setting.RemoteDebuggingPort = 8088
CefSharp.Cef.Initialize(setting)
browser = New ChromiumWebBrowser("https://www.google.com/") With {
.Dock = DockStyle.Fill
}
Panel1.Controls.Add(browser)
browser.Load(TextBox1.Text)
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
browser.Load(TextBox1.Text)
End Sub
End Class
Form1.Design.vb
- Code: Select all
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()>
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.Button5 = New System.Windows.Forms.Button()
Me.Panel1 = New System.Windows.Forms.Panel()
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(336, 14)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(210, 26)
Me.TextBox1.TabIndex = 4
Me.TextBox1.Text = "http://vmars.us/SafeBrowser/SafeBrowserHome.html"
'
'Button5
'
Me.Button5.Location = New System.Drawing.Point(552, 14)
Me.Button5.Name = "Button5"
Me.Button5.Size = New System.Drawing.Size(75, 32)
Me.Button5.TabIndex = 5
Me.Button5.Text = "Button5"
Me.Button5.UseVisualStyleBackColor = True
'
'Panel1
'
Me.Panel1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Panel1.Location = New System.Drawing.Point(9, 63)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(1201, 602)
Me.Panel1.TabIndex = 7
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(9.0!, 20.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(1222, 677)
Me.Controls.Add(Me.Button5)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Panel1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents TextBox1 As TextBox
Friend WithEvents Button5 As Button
Friend WithEvents Panel1 As Panel
End Class