ImageLocation auslesen von Picturebox die zur Laufzeit erstellt wurde

  • VB.NET

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

    ImageLocation auslesen von Picturebox die zur Laufzeit erstellt wurde

    Ich möchte den Image Pfad aus einer zur laufzeit erstellten Picturebox auslesen.
    Ich habe viele Pictureboxen (1301) :D

    VB.NET-Quellcode

    1. For I = iMax To 0 Step -25
    2. 'Dim name As String = "PicBox_" & ID
    3. Dim Picturebox_1 As New PictureBox
    4. Picturebox_1.Name = "Picturebox_" & ID
    5. 'Picturebox_1.Image = Image.FromFile(Application.StartupPath & "\gfx\box.png")
    6. Picturebox_1.Location = New Point(__, I)
    7. Picturebox_1.Size = New Size(25, 25)
    8. Picturebox_1.BackgroundImage = Image.FromFile(Application.StartupPath & "\gfx\ms_leave.png")
    9. Me.Controls.Add(Picturebox_1)
    10. Locations(ID) = Picturebox_1.Location.Y & "." & Picturebox_1.Location.X
    11. ID = ID + 1
    12. Picturebox_1.Update()
    13. AddHandler Picturebox_1.Click, AddressOf clickevent
    14. AddHandler Picturebox_1.MouseEnter, AddressOf ConvertEventArgs
    15. AddHandler Picturebox_1.MouseLeave, AddressOf Ms_Leave
    16. Next


    Nun möchte ich später mit dem clickevent auslesen können welcher Bildpfad die Picturebox hat.
    Ich habs versucht mit :

    VB.NET-Quellcode

    1. MsgBox(CType(sender, PictureBox).ImageLocation)


    aber er gibt mir immer nur "" zurück also nichts.

    Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „Graphicscore“ ()

    Das gefällt der Nachbarin:

    VB.NET-Quellcode

    1. Picturebox_1.ImageLocation = Application.StartupPath & "\gfx\ms_leave.png"
    2. MessageBox.Show(Picturebox_1.ImageLocation)
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!