|
Option Explicit On
Option Strict On
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.Size = New Size(320, 220)
RadioButton1.Location = New Point(15, 130)
RadioButton1.Text = _
"Label 2 dem Label1 zuzuordnen macht es durchsichtig"
RadioButton2.Location = New Point(15, 150)
RadioButton2.Text = "Label2 dem Form zuzuordnen macht es undurchsichtig"
With Label1
.BackColor = Color.Yellow
.ForeColor = Color.Blue
.Font = New Font("Microsoft Sans Serif", 15.75, FontStyle.Regular)
.Location = New Point(32, 40)
.Text = "Ich bin Label1" & vbCrLf & "mit einer Beschriftung"
End With
With Label2
.BackColor = Color.Transparent
.ForeColor = Color.Black
.Font = New Font("Microsoft Sans Serif", 15.75, FontStyle.Regular)
.Location = New Point(42, 50)
.BringToFront()
.Text = "Ich bin Label 2"
End With
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
Label2.Parent = Label1
Dim p As Point = Label1.PointToScreen(Label1.Location)
Dim pt As New Point(p.X - 22, p.Y - 30)
Label2.Location = Label1.PointToClient(pt)
End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
Label2.Parent = Me
Label2.Location = New Point(42, 50)
Label2.BringToFront()
End Sub
End Class |