So, ich habe jetzt mal versucht das Ganze irgendwie umzusetzen allerdings mäßig erfolgreich
Hier der Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Load
ReDim pb(10)
For i As Integer = 1 To 10
pb(i) = New PictureBox
pb(i).Width = 32 : pb(i).Height = 32
pb(i).Location = New Point(CInt(My.Computer.FileSystem.ReadAllText( _
"config\pb" & i & "\locationx.ini")), _
CInt(My.Computer.FileSystem.ReadAllText("config\pb" & i & _
"\locationy.ini")))
pb(i).ImageLocation = "config\pb" & i & "\pbBild.bmp"
pb(i).AllowDrop = True
Me.Controls.Add(pb(i))
AddHandler pb(i).MouseDown, AddressOf Pic_MouseDown
AddHandler pb(i).MouseUp, AddressOf Pic_MouseUp
AddHandler pb(i).MouseClick, AddressOf PictureBox_Click
AddHandler pb(i).MouseUp, AddressOf Pic_MouseUp
AddHandler Me.Load, AddressOf pbLocationSchreiben
Next i
End Sub
'PictureBox:
Private Sub PictureBox_DragEnter(ByVal sender As Object, ByVal e As _
System.Windows.Forms.DragEventArgs) Handles pb(i).DragEnter
MouseOverPicture = True
DragEnterSub(e)
End Sub
Private Sub PictureBox_DragDrop(ByVal sender As Object, ByVal e As _
System.Windows.Forms.DragEventArgs) Handles pb(i).DragDrop
geticon((CType(e.Data.GetData(DataFormats.FileDrop), Array).GetValue( _
0).ToString), 1, pb(i))
DragDropSub(e, 1)
MouseOverPicture = False
End Sub
Private Sub PictureBox_mouseEnter(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles pb(i).MouseEnter
If Not MouseOverPicture Then
pb(i).BorderStyle = BorderStyle.FixedSingle
End If
End Sub
Private Sub PictureBox_mouseLeave(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles pb(i).MouseLeave
pb(i).BorderStyle = BorderStyle.None
End Sub
Private Sub PictureBox_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles pb(i).Click
Try
System.Diagnostics.Process.Start(System.IO.File.ReadAllText( _
"config\pb" & i & "\pbconfig.ini"))
Catch ex As Exception
MsgBox("Sie haben dem Feld noch keine Anwendung zugeordnet, die" & _
"Anwendung/Datei wurde mittlerweile gelöscht/verschoben, oder es" & _
"ist kein Programm mit dem Dateiformat verknüpft.", _
MsgBoxStyle.Critical)
End Try
End Sub Ich möchte also die 5 PictureBox Events jeweils mit der ausgewählten Picturebox aufrufen. Alleridngs bekomme ich die Verknüpfung nicht hin, siehe auch AddHandler Bereich.
Es ist mir klar, dass es so nicht funktionieren kann, aber habe nicht wirklich eine Idee. Muss ich für jede Prozedur einen zusätzlichen Paramter irgendwie einbabuen der auf die Nr. der PB prüft? |