vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Erstellen von dynamischen Kontextmen?s - wann immer Sie sie brauchen!  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2024
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

VB.NET - Ein- und Umsteiger
Re: Tablelayoutcontainer Controls Move 
Autor: Gizmo2011
Datum: 15.11.12 10:33

Ich habe mir das BSP angesehen da ich noch nicht controls verschoben habe und ich neu auf dem Gebiet bin.

Public Class Form1
 
    Dim _dragging As Boolean = False
    Dim _controlPoint As Point
 
    Private Sub Label1_MouseDown(ByVal sender As System.Object, ByVal e As _
      MouseEventArgs) _
                                                                        Handles _
                                                                        Label1._
                                                                        MouseDo_
                                                                        wn
        Dim lbl As Label = DirectCast(sender, Label)
 
        ' If the label is somehow free-floating we'll lust let it be
        If (TableLayoutPanel1.Contains(lbl)) Then
 
            Dim mousePoint As Point = Cursor.Position ' mouse position in 
            ' screen coordinates
            _controlPoint = lbl.PointToClient(mousePoint) ' offset from (0, 0) 
            ' in label coordinates
 
            ' This is the location of the label's (0, 0) in screen coordinates.
            Dim screenLocation As Point = New Point(mousePoint.X - _
              _controlPoint.X, _
                                                    mousePoint.Y - _
                                                    _controlPoint.Y)
 
            ' Remove the label from the panel and make it a child of the form; 
            ' bring it to 
            'the front to make sure it's not hidden behind the panel.
            TableLayoutPanel1.Controls.Remove(lbl)
            Me.Controls.Add(lbl)
            lbl.BringToFront()
 
            ' Move the label to the position it was in before we removed it 
            ' from the table, and
            ' indicate the control is being dragged.
            lbl.Location = Me.PointToClient(screenLocation)
            _dragging = True
        End If
    End Sub

MFG Gizmo

alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Tablelayoutcontainer Controls Move1.476Gizmo201115.11.12 09:44
Re: Tablelayoutcontainer Controls Move938ModeratorDaveS15.11.12 10:21
Re: Tablelayoutcontainer Controls Move901Gizmo201115.11.12 10:33
Re: Tablelayoutcontainer Controls Move1.008ModeratorDaveS15.11.12 12:09
Re: Tablelayoutcontainer Controls Move867ModeratorDaveS16.11.12 19:15

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2024 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel