Comboboxen in Form anordnen

  • VB.NET

Es gibt 3 Antworten in diesem Thema. Der letzte Beitrag () ist von nemesis.

    Comboboxen in Form anordnen

    Hallo,

    ich möchte eine dynamische Anzahl Comboboxen und die zugehörigen Textboxen in meiner Form anordnen. Dazu durchlaufe ich diese in einer Schleife:

    VB.NET-Quellcode

    1. For Each myControl As Control In Controls
    2. If TypeOf myControl Is ComboBox Then
    3. myControl.Location.X = X
    4. End If
    5. Next

    aber er lässt mich so die Platzierung nicht vornehmen. Wie machtz man soetwas richtig?

    Vielen Dank!
    Hey,

    weise dem Control eine vollständig neue Position zu. Im folgenden Beispiel wird das Control um 50px nach rechts verschoben:

    VB.NET-Quellcode

    1. For Each myControl As Control In Controls
    2. If TypeOf myControl Is ComboBox Then
    3. myControl.Location = New Point(myControl.Location.X + 50, myControl.Location.Y)
    4. End If
    5. Next

    Relevant für dich ist insbesondere Zeile 3 mit der Anweisung 'New Point()'.

    Gruß, Manschula
    ich habs jetzt wie folgt:

    VB.NET-Quellcode

    1. Private Sub Place_Boxes()
    2. Dim XK As Integer = 36
    3. Dim YK As Integer = 12
    4. For Each myControl As Control In Controls
    5. If TypeOf myControl Is ComboBox Then
    6. myControl.Location = New Point(XK, YK)
    7. XK = XK + 27
    8. End If
    9. Next
    10. End Sub

    funktioniert wunderbar :)

    DAnke!

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „nemesis“ ()