Hi leutz,
habe lange versucht mehrere Buttons mit Control.Add(Button()) in meine Form zu holen. Ganz kurz was ich vorhabe:
Ich möchte mehrere Panels (gleich aufgebaut) mit den gleichen Buttons,checkboxen dynamisch in meine Form holen, die Anzahl hängt von einer Db ab.Ich habe hier mal ganz einfach 2solcher panels veruscht anzuzeigen. (ne ganz einfache version). Das problem das ich habe ist, dass er mir den Inhalt des ersten panels, das ich hinzufüge super anzeigt, nur nummer 2 ist ohne inhalt, obwohl ich sogar neue buttons mit new erstelle
Ne Idee woran das liegen könnte?
habe lange versucht mehrere Buttons mit Control.Add(Button()) in meine Form zu holen. Ganz kurz was ich vorhabe:
Ich möchte mehrere Panels (gleich aufgebaut) mit den gleichen Buttons,checkboxen dynamisch in meine Form holen, die Anzahl hängt von einer Db ab.Ich habe hier mal ganz einfach 2solcher panels veruscht anzuzeigen. (ne ganz einfache version). Das problem das ich habe ist, dass er mir den Inhalt des ersten panels, das ich hinzufüge super anzeigt, nur nummer 2 ist ohne inhalt, obwohl ich sogar neue buttons mit new erstelle
Ne Idee woran das liegen könnte?
VB.NET-Quellcode
- Imports System.Windows.Forms
- Public Class Form1
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- CreateMyTabPage()
- End Sub
- Public Sub CreateMyTabPage()
- Dim panel2 As New Panel()
- Dim xLabel As Integer = 5
- Dim yLabel As Integer = 8
- '----------------
- panel2.Location = New Point(0, 30)
- panel2.Size = New Size(364, 243)
- panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
- Dim location As System.Drawing.Point
- location.X = 5
- location.Y = 7
- Dim buttonPasswdCh As New Button()
- Dim buttonDeleteUser As New Button()
- Dim panelInside As Panel 'New addUderHelperClass()
- panelInside = addUserHelperFunction(buttonPasswdCh, buttonDeleteUser, location.X, location.Y)
- panel2.Controls.Add(panelInside)
- location.X = 5
- location.Y += 102
- Dim buttonPasswdCh2 As New Button()
- Dim buttonDeleteUser2 As New Button()
- Dim panelInside2 As Panel 'New addUderHelperClass()
- panelInside2 = addUserHelperFunction(buttonPasswdCh2, buttonDeleteUser2, location.X, location.Y)
- panel2.Controls.Add(panelInside2)
- location.X = 5
- location.Y += 102
- 'Me.Controls.Add(buttonPasswdCh)
- 'Me.Controls.Add(buttonPasswdCh2)
- Me.Controls.Add(panelInside)
- Me.Controls.Add(panelInside2)
- End Sub
- Private Function addUserHelperFunction(ByVal buttonPassWd As Button, ByVal buttonDelUser As Button, ByVal locationX As Integer, ByVal locationY As Integer) As Panel
- Dim panelInside As New Panel()
- MsgBox(locationX & " " & locationY)
- Dim xLabel As Integer = locationX
- Dim yLabel As Integer = locationY
- panelInside.Location = New Point(0, yLabel)
- panelInside.Size = New Size(350, 100)
- panelInside.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
- buttonPassWd.Location = New System.Drawing.Point(xLabel + 236, yLabel - 4) '(xLabel + 236, yLabel - 2)
- buttonPassWd.Size = New System.Drawing.Size(51, 23)
- buttonPassWd.Text = "Passwd"
- buttonDelUser.Size = New System.Drawing.Size(51, 23)
- buttonDelUser.Location = New System.Drawing.Point(xLabel + 290, yLabel - 4)
- buttonDelUser.Text = "Delete"
- 'AddHandler buttonDelUser.Click, AddressOf buttonDelUser_Click
- 'füge buttons hinzu
- panelInside.Controls.Add(buttonPassWd)
- panelInside.Controls.Add(buttonDelUser)
- Return panelInside
- End Function
- End Class
Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „gomanza“ ()