Files
RecordOrganizer/app/DD-Record-Organiser/frmTestvb.vb
2015-09-04 08:12:24 +02:00

60 lines
2.0 KiB
VB.net

Public Class frmTestvb
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If CntrlExistsIn("btnEntity2", Panel1) = True Then
MsgBox("Control2 existiert")
End If
Dim btn As New Button
btn.Name = "btnEntity2"
btn.Text = "Button 2"
btn.Size = New Size(160, 45)
btn.FlatStyle = FlatStyle.Flat
btn.BackColor = Color.Goldenrod
btn.FlatAppearance.BorderColor = Color.Gold
Panel1.Controls.Add(btn)
btn.Location = New Point(177, 12)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If CntrlExistsIn("btnEntity1", Panel1) = True Then
MsgBox("Control1 existiert")
End If
Dim btn As New Button
btn.Name = "btnEntity1"
btn.Text = "Button 1"
btn.Size = New Size(160, 45)
btn.FlatStyle = FlatStyle.Flat
btn.BackColor = Color.DeepSkyBlue
btn.FlatAppearance.BorderColor = Color.LightSkyBlue
Panel1.Controls.Add(btn)
btn.Location = New Point(6, 12)
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If CntrlExistsIn("btnEntity3", Panel1) = True Then
MsgBox("Control3 existiert")
End If
Dim btn As New Button
btn.Name = "btnEntity3"
btn.Text = "Button 3"
btn.Size = New Size(160, 45)
btn.FlatStyle = FlatStyle.Flat
btn.BackColor = Color.DarkViolet
btn.FlatAppearance.BorderColor = Color.Plum
Panel1.Controls.Add(btn)
btn.Location = New Point(348, 12)
End Sub
Function CntrlExistsIn(ctrlName As String, parent As Control) As Boolean
Dim bResult As Boolean = False
For Each elem As Control In parent.Controls
If elem.Name = ctrlName Then
bResult = True
Exit For
End If
Next
Return bResult
End Function
End Class