I have problem with PictureBox
.
When I am docking PictureBox
to the top right, it's hidding a part of label which is on the center of form. How I can bring to front label over PictureBox
? I am thinking that problem is with docking declaration in both (Image
and Label
declaration), that's why it's hidden by PictureBox
.
How I can do this properly?
Form Declaration:
$Form = New-Object System.Windows.Forms.Form
$Form.Text = "Something"
$Form.StartPosition = "CenterScreen"
$Form.Topmost = $True
$Form.BackColor = "White"
$Form.Width = [System.Windows.Forms.SystemInformation]::PrimaryMonitorSize.Width
$Form.Height = [System.Windows.Forms.SystemInformation]::PrimaryMonitorSize.Height - 50
#$Form.AutoSize = $True
$Form.AutoSizeMode = "GrowAndShrink"
$Form.ControlBox = $false
$Form.MinimumSize = New-Object System.Drawing.Size(1280,1024)
$Form.MaximumSize = New-Object System.Drawing.Size(1920,1080)
Image declaration:
$Image = [system.drawing.image]::FromFile("C:\xxx.png")
$pictureBox = new-object Windows.Forms.PictureBox
$pictureBox.Dock = [System.Windows.Forms.DockStyle]::Right
$pictureBox.BackColor = "Transparent"
#$pictureBox.Anchor = [System.Windows.Forms.AnchorStyles]::Right
$pictureBox.AutoSize = $True
$pictureBox.Image=$Image
$Form.Controls.Add($pictureBox)
Label declaration:
$redLabel1 = New-Object System.Windows.Forms.Label
$redLabel1.Location = New-Object System.Drawing.Size($Form.Width, $Form.Height)
$redLabel1.AutoSize = $False
$redLabel1.TextAlign = "MiddleCenter"
$redLabel1.Dock = "Fill"
$redLabel1.Text = "Something"
$redLabel1.ForeColor = "Red"
$redLabel1.BackColor = "Transparent"
$Font = New-Object System.Drawing.Font("Arial", 55, [System.Drawing.FontStyle]::Bold)
$redLabel1.Font = $Font
$Form.Controls.Add($redLabel1)
EDIT:
BringToFront()
method already tested and working in 50%. Text is not centered in forms, and when label meet PictureBox
, text is wrapped.. I would like that label will somehow skip PictureBox
..
Screenshot: