OK questo l'evento che gestisce i tasti delle picturebox contenute nel contenitore di FlowLayoutPanel (con tutti i controlli possibili annessi) funziona a meraviglia è spettacolare l'effetto grafico che ne viene fuori
:
codice:
Private Sub PictureBox_PreviewKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles ImagesFlowLayoutPanel.PreviewKeyDown, MyBase.PreviewKeyDown
If e.KeyValue = Keys.Escape Then Me.DialogResult = DialogResult.Cancel : Exit Sub
Dim Contenitore As FlowLayoutPanel = sender.parent,
PictureBoxFocused As PictureBox = GetFocusedControls(Contenitore)
If PictureBoxFocused Is Nothing Then Exit Sub
Select Case e.KeyValue
Case Keys.Right, Keys.Left ' tasti destra e sinistra
With Contenitore ' FlowLayoutPanel
Dim Index As Integer = .Controls.IndexOf(PictureBoxFocused),
Direction As Integer = IIf(e.KeyValue = Keys.Left, -1, 1)
Index += Direction
If Index < .Controls.Count And Index >= 0 Then Seleziona(Contenitore, .Controls(Index))
End With
Case Keys.Up, Keys.Down ' tasti Up e Down
With Contenitore ' FlowLayoutPanel
.SuspendLayout()
Dim Direction As Integer = IIf(e.KeyValue = Keys.Up, -1, 1)
.AutoScrollPosition = Point.Subtract(New Point(0, (PictureBoxFocused.Height / 2) * Direction), .AutoScrollPosition)
Dim AdiacentPicture As PictureBox = .GetChildAtPoint(New Point(PictureBoxFocused.Left + 10, IIf(Direction < 0, PictureBoxFocused.Top, PictureBoxFocused.Bottom) + 10 * Direction))
If AdiacentPicture IsNot Nothing Then Seleziona(Contenitore, AdiacentPicture)
.ResumeLayout(True)
End With
Case Keys.Return ' Tasto Invio
If Not Multiselect Then PictureBoxDoubleClick(PictureBoxFocused, Nothing) Else Beep()
Case Keys.Cancel, Keys.Back ' tasti Canc e BackSpace
RimuoviLink_LinkClicked(RimuoviLink, Nothing)
End Select
End Sub
unico Neo, non so del perchè il tasto Canc (in rosso) non fa scattare questo evento, di fatti ho dovuto intercettare il Tasto BackSpace per l'eliminazione dell'immagine...sarebbe stato perfetto
[COLOR=red]