Picturebox Ansprechen

  • VB.NET

Es gibt 2 Antworten in diesem Thema. Der letzte Beitrag () ist von TheDark.

    Picturebox Ansprechen

    Ich habe dießen Code Hier

    VB.NET-Quellcode

    1. Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click Dim PB As New Move_PictureBox
    2. With PB
    3. .BackColor = Color.Black
    4. .Size = New Point(100, 100) .Name = Textbox1.Text
    5. End With
    6. Me.Controls.Add(PB)
    7. End Sub
    8. End Class
    9. Public Class Move_PictureBox : Inherits PictureBox
    10. Dim Beweglich As Boolean = True
    11. Dim nStartPos As Point
    12. Dim nDragPos As Point
    13. Shadows Sub PictureBox_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
    14. If Beweglich Then
    15. If e.Button = Windows.Forms.MouseButtons.Left Then
    16. nStartPos = Me.Location
    17. nDragPos = Me.PointToScreen(New Point(e.X, e.Y))
    18. End If
    19. End If
    20. End Sub
    21. Shadows Sub PictureBox_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
    22. If Beweglich Then
    23. If e.Button = Windows.Forms.MouseButtons.Left Then
    24. Dim nCurPos As Point = Me.PointToScreen(New Point(e.X, e.Y))
    25. Me.Location = New Point(nStartPos.X + nCurPos.X - nDragPos.X, _
    26. nStartPos.Y + nCurPos.Y - nDragPos.Y)
    27. End If
    28. End If
    29. End Sub




    nun möchte ich eine bestimmte picturebox ansprechen deswegen wird ihr beim erstellen ein Name der in Textbox1 steht gegeben.

    Aber wie mache ich das jetzt genau ?

    ich möchte bloß einer bestimmten picturebox deren Name in Textbox1 eingegeben wird eine andere Backgroundcolor geben.

    Bitte um Hilfe.