Hi Board,
hab jetzt folgendes gebastelt. Ich sags vornweg es funzt leider net so wie ich will.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button2.Click
Dim i As Integer
For i = 1 To 10
Dim newtab As New myTabPage("tb" & i.ToString, "tabpage" & _
i.ToString)
TabControl1.TabPages.Add(newtab)
newtab.AddControls(newtab)
Next
End Sub
-------------------------------------------------------------------------------_
-------------------------------
Public Class myTabPage
Inherits TabPage
Friend WithEvents TabPage1 As System.Windows.Forms.TabPage
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents txtinput As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents Panel1 As System.Windows.Forms.Panel
Friend WithEvents Panel2 As System.Windows.Forms.Panel
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Button2 As System.Windows.Forms.Button
Public Sub AddControls(ByVal objTabPage As TabPage)
objTabPage.Controls.Add(Label4)
objTabPage.Controls.Add(Me.Label3)
objTabPage.Controls.Add(Me.Label2)
objTabPage.Controls.Add(Me.Panel2)
objTabPage.Controls.Add(Me.Panel1)
objTabPage.Controls.Add(Me.PictureBox1)
objTabPage.Controls.Add(Me.Button1)
objTabPage.Controls.Add(Me.txtinput)
objTabPage.Controls.Add(Me.Label1)
objTabPage.Controls.Add(Me.DataGrid1)
objTabPage.Location = New System.Drawing.Point(4, 22)
objTabPage.Name = "TabPage1"
objTabPage.Size = New System.Drawing.Size(840, 446)
objTabPage.TabIndex = 0
objTabPage.Text = "TabPage1"
'
'In der nächsten Zeile bekomm ich nur - Der Objektverweis wurde nicht auf eine
' Objektinstanz festgelegt.
Me.Label3.Location = New System.Drawing.Point(8, 128)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(312, 16)
Me.Label3.TabIndex = 8
Me.Label3.Text = "Diagramm:"
'
Me.Label2.Location = New System.Drawing.Point(8, 288)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(304, 16)
Me.Label2.TabIndex = 7
Me.Label2.Text = "Verteilung:"
'
Me.Panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.Panel2.Location = New System.Drawing.Point(8, 144)
Me.Panel2.Name = "Panel2"
Me.Panel2.Size = New System.Drawing.Size(312, 136)
Me.Panel2.TabIndex = 6
'
Me.Panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.Panel1.Location = New System.Drawing.Point(8, 304)
Me.Panel1.Name = "Panel1"
Me.Panel1.Size = New System.Drawing.Size(312, 136)
Me.Panel1.TabIndex = 5
'
Me.PictureBox1.BorderStyle = _
System.Windows.Forms.BorderStyle.FixedSingle
Me.PictureBox1.Location = New System.Drawing.Point(592, 160)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(56, 280)
Me.PictureBox1.TabIndex = 4
Me.PictureBox1.TabStop = False
'
Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup
Me.Button1.Location = New System.Drawing.Point(456, 136)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(120, 24)
Me.Button1.TabIndex = 3
Me.Button1.Text = "Hinzufügen / Messen"
'
Me.txtinput.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.txtinput.Location = New System.Drawing.Point(456, 112)
Me.txtinput.Name = "txtinput"
Me.txtinput.Size = New System.Drawing.Size(192, 20)
Me.txtinput.TabIndex = 2
Me.txtinput.Text = ""
AddHandler Button1.Click, AddressOf ButtonClick
End Sub
Private Sub ButtonClick(ByVal sender As Object, ByVal e As System.EventArgs)
MsgBox("Das ist die tabpage ")
End Sub
Public Sub New(ByVal Text As String, ByVal Name As String)
MyBase.New(Text)
End Sub Wie und wo liegt hier der Fehler?
Ich dachte eigentlich das es richtig wäre die Sub die die Controls erstellt mit in die Klasse reinzunehmen. Diese Classe könnte man dann ja in ein eigene Datei schmeißen und sich anderweitig im Projekt noch mal drauf beziehen.
So dachte ich
Danke für jegliche Hilfe
Spassmann |