Control zur Laufzeit mit der Maus auswälen

  • VB.NET

Es gibt 2 Antworten in diesem Thema. Der letzte Beitrag () ist von Tabes.

    Control zur Laufzeit mit der Maus auswälen

    Hallo Leute,
    ich stehe heute mal wieder etwas auf dem Schlauch...

    Ich möchte eine zur Laufzeit erstellte und mit der Maus aktivierten TextBox so wie in der IDE darstellen. Dieses funktioniert auch soweit.

    Meine Vorlage war:
    http://dotnet-snippets.de/dns/vbnet-...ed-SID605.aspx

    Mein Problem ist jetzt, wenn ich die Shift- Taste drücke, möchte ich eine Mehrfachauswahl erreichen

    Meine Auswahl erfolgt in etwa so.

    VB.NET-Quellcode

    1. Public Sub Select_Control(ByRef objControl As Control, Optional ByVal Multiple_Selection As Boolean = False)
    2. If Multiple_Selection = False Then
    3. If InResizeMode = True Or MoveControl = True Then Exit Sub
    4. End If
    5. meControl = objControl
    6. meGraphics = meControl.CreateGraphics()
    7. With meGraphics
    8. 'Rahmen
    9. .DrawRectangle(Pens.Gray, New Rectangle(meControl.Location.X - (GrabSize / 2), meControl.Location.Y - (GrabSize / 2), _
    10. meControl.Width + GrabSize, meControl.Height + GrabSize))
    11. End With
    12. 'Positionen für die GrabRects in der Reihenfolge:
    13. 'TopLeft, TopMiddle, TopRight, MiddleLeft, MiddleRight, BottomLeft,BottomMiddle,BottomRight
    14. Dim GrabRectPos() As Point = { _
    15. New Point(meControl.Location.X - GrabSize, meControl.Location.Y - GrabSize), _
    16. New Point(meControl.Location.X + (meControl.Width / 2) - (GrabSize / 2), meControl.Location.Y - GrabSize), _
    17. New Point(meControl.Location.X + meControl.Width, meControl.Location.Y - GrabSize), _
    18. New Point(meControl.Location.X - GrabSize, meControl.Location.Y + (meControl.Height / 2) - (GrabSize / 2)), _
    19. New Point(meControl.Location.X + (meControl.Width), meControl.Location.Y + (meControl.Height / 2) - (GrabSize / 2)), _
    20. New Point(meControl.Location.X - GrabSize, meControl.Location.Y + (meControl.Height)), _
    21. New Point(meControl.Location.X + (meControl.Width / 2) - (GrabSize / 2), meControl.Location.Y + (meControl.Height)), _
    22. New Point(meControl.Location.X + meControl.Width, meControl.Location.Y + (meControl.Height))}
    23. For i = LBound(GrabRects) To UBound(GrabRects)
    24. GrabRects(i).Location = GrabRectPos(i)
    25. GrabRects(i).Size = New Size(GrabSize, GrabSize)
    26. GrabRects(i).BackColor = GrabRectColor
    27. GrabRects(i).Parent = meParent
    28. GrabRects(i).Visible = True
    29. Next
    30. meForm.Refresh()
    31. End Sub


    Wobei die Steuerelemente in einer For Next Schleife an die Funktion
    übergeben werden. Hiebei wird jedoch dann immer nur das letzte Element
    aktiviert. Wie ist dies zu realisieren?



    Vielen Dank.



    Gruß

    Tabes