PictureBox soll sich bei gefundenen Datensatz Aktualisiren, ist mein Ansatz richtig?

  • VB.NET

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

    PictureBox soll sich bei gefundenen Datensatz Aktualisiren, ist mein Ansatz richtig?

    Hallo Forum

    Ich suche in einer Access Datenbank einen Datensatz, ich hole mir dort unter anderem die Pfadangaben für meine PictureBox.
    Nur leider Aktualisiert sich die Box nicht.

    Hier mal meine Sub..... vielleicht kann mir da jemand helfen.

    VB.NET-Quellcode

    1. Private Sub SucheFoto()
    2. Try
    3. If PictureBox2.Image IsNot Nothing Then PictureBox2.Image.Dispose()
    4. Dim drv As DataRowView = CType(bs.Current, DataRowView) ' Sicht auf aktuelle Zeile
    5. Dim pfad = drv.Item("BildPfad").ToString ' Pfad zur Bilddatei!
    6. Debug.WriteLine(drv.Item("BildPfad")) ' Den Pfad bekomme ich so übergeben [ C:\Bilder\Test.jpg ]
    7. Dim fs As New FileStream("BildPfad", FileMode.Open)
    8. Debug.WriteLine("BildPfad")
    9. Dim bmp As New Bitmap(fs)
    10. PictureBox2.Image = bmp
    11. fs.Close()
    12. Catch ex As Exception
    13. MessageBox.Show(ex.Message)
    14. End Try
    15. End Sub