Announcement

Collapse
No announcement yet.

Erstellen und Handeln einer Picturebox zur Laufzeit

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Erstellen und Handeln einer Picturebox zur Laufzeit

    Hallo könnte mir bitte wer weiterhelfen?
    Ich erstelle zur laufzeit eine Picturebox und müsste davon das image lesen und schreiben is das irgendwie möglich?


    Das erstellen geht:

    Private Sub Create()
    Dim pic As New PictureBox
    pic.Name = "pic1"
    AddHandler pic.MouseDown, AddressOf PicMouseDown
    AddHandler pic.MouseUp, AddressOf PicMouseUp
    AddHandler pic.MouseMove, AddressOf PicMouseMove
    pic.Width = 100
    pic.Height = 100
    pic.SizeMode = PictureBoxSizeMode.StretchImage
    pic.Image = New Bitmap(PhotoDir & File.Name)
    Me.Controls.Add(pic)
    End Sub

    das Löschen auch:
    Private Sub Create()
    For Each tmp As Control In Me.Controls
    If tmp.Name = "pic1"
    Me.Controls.Remove(tmp)
    End If
    Next





    aber auf das erstellte image kan man nicht zugreifen:

    For Each tmp In Me.Controls
    If tmp.Name = "pic1"
    Exit For
    End If
    Next

    tmp.image=nothing 'Geht nicht




    Oder bin ich da total am falschen weg?

  • #2
    naja das kann ja nicht funktionieren TMP ist eine Variable die du nur für den For Block deklariert hast.
    [highlight=vbnet]
    Dim tmp as Control
    For Each tmp In Me.Controls
    If tmp.Name = "pic1"
    Exit For
    End If
    Next
    tmp.image=nothing
    '------- oder ----
    For Each tmp as Control In Me.Controls
    If tmp.Name = "pic1"
    tmp = ctype(tmp,picturebox)
    tmp.Image = Nothing
    Exit For
    End If
    Next
    [/highlight]

    Und makiere deinen Code ab jetzt bitte mit der Highlight funktion dann werdne die Beiträge besser lesbar.
    Unsere Jugend ist unerträglich, unverantwortlich und entsetzlich anzusehen! - Aristoteles

    Comment


    • #3
      Vielen dank

      Genau das wars was ich gesucht habe.

      Code:
      tmp = ctype(tmp,picturebox)
      Vielen dank

      Echt super Forum

      Comment

      Working...
      X