ERLEDIGT
NEIN
NEIN
ANTWORTEN
0
0
ZUGRIFFE
1661
1661
EMPFEHLEN
-
08.01.07 16:29 #1
Hellas,
also folgendes: Ich habe ein großes Panel, welches sozusagen als Container für mehrere kleinere Panels diehnt. Das große besitzt auch noch Scrollleisten (AutoScroll), während die kleineren einfach nur eine fixe Größe haben.
So, nun soll man diese kleinen Panels im großen beliebig Verschieben können (am Ende soll es ein kontrolliertes Drag and Drop sein). Im Internet hab ich auch ein Beispiel gefunden, aber das war leider ohne Scrollleisten.
Wie dem auch sei, ich habe bereits eine Lösung, aber mit der bin ich noch nicht wirklich zu frieden. Habt ihr vielleicht bessere Ideen, Tipps, Hinweise?
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
Dim isMouseDown As Boolean Dim mousePos As Point Dim ctlPos As Point Dim pnl As Panel Dim scrX As Double Dim scrY As Double Private Sub DateControl_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown isMouseDown = True Me.BringToFront() mousePos = Me.PointToScreen(New Point(e.X, e.Y)) ctlPos = Me.Location pnl = CType(Me.Parent, Panel) scrX = pnl.AutoScrollPosition.X scrY = pnl.AutoScrollPosition.Y End Sub Private Sub DateControl_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove If Not isMouseDown Then Exit Sub Dim pos As Point = Me.PointToScreen(New Point(e.X, e.Y)) Dim x As Integer = ctlPos.X + pos.X - mousePos.X Dim y As Integer = ctlPos.Y + pos.Y - mousePos.Y If x > 0 Then If x < (pnl.Width - Me.Width) Then Me.Left = x ElseIf x >= (pnl.Width - Me.Width) And (pnl.DisplayRectangle.Width - Math.Round(scrX)) >= pnl.Width Then scrX = scrX + 0.7 pnl.AutoScrollPosition = New Point(Math.Round(scrX), 0) If (pnl.DisplayRectangle.X + pnl.Controls.Item(pnl.Controls.Count - 1).Location.X) > 0 Then Me.Left = x End If End If ElseIf x <= 0 And Math.Round(scrX) > 0 Then scrX = scrX - 0.7 pnl.AutoScrollPosition = New Point(Math.Round(scrX), 0) Me.Left = 0 End If If y > 0 Then If y < (pnl.Height - Me.Height) Then Me.Top = y ElseIf y >= (pnl.Height - Me.Height) And (pnl.DisplayRectangle.Height - Math.Round(scrY)) >= pnl.Height Then scrY = scrY + 0.7 pnl.AutoScrollPosition = New Point(Math.Round(scrX), Math.Round(scrY)) If (pnl.DisplayRectangle.Y + pnl.Controls.Item(pnl.Controls.Count - 1).Location.Y) > 0 Then Me.Left = y End If End If ElseIf y <= 0 And Math.Round(scrY) > 0 Then scrY = scrY - 0.7 pnl.AutoScrollPosition = New Point(Math.Round(scrX), Math.Round(scrY)) Me.Top = 0 End If pnl.Controls.Item(pnl.Controls.Count - 1).Text = (pnl.DisplayRectangle.Width - Math.Round(scrX)).ToString End Sub
lg BillieFann Ég Fjalli Fallega Steina
Faldi Dá Alla Vildi Deim Leyna
Huldi Dar Hellisskúta Heillasteina
Alla Mína Una eth slegu Óskasteina
Ähnliche Themen
-
Drag 'n' Drop mit JS
Von ts230 im Forum Javascript & AjaxAntworten: 23Letzter Beitrag: 26.08.08, 10:23 -
Drag and Drop
Von Mo1k im Forum Javascript & AjaxAntworten: 3Letzter Beitrag: 03.05.08, 17:44 -
Drag and Drop
Von Busi im Forum Swing, Java2D/3D, SWT, JFaceAntworten: 5Letzter Beitrag: 25.10.07, 15:39 -
Drag & Drop mit <tr> ?!
Von ev0lst im Forum Javascript & AjaxAntworten: 3Letzter Beitrag: 12.08.07, 10:23 -
SWT: Ghosted Drag-Image bei Drag & Drop
Von snake_plissken im Forum Swing, Java2D/3D, SWT, JFaceAntworten: 1Letzter Beitrag: 15.04.06, 23:36





Zitieren
Login





