Nasty2
July 18th, 2005, 11:11 AM
on form click im creating a panel with 11 labels in it:
Private Sub DrawEntity(ByVal mouseDownPoint As System.Drawing.Point)
Dim panelSize As New System.Drawing.Size(150, 250)
Dim newPanel As New Panel
newPanel.Location = mouseDownPoint
newPanel.BorderStyle = BorderStyle.FixedSingle
newPanel.Size = panelSize
Me.Controls.Add(newPanel)
Dim newLabel As New Label
Dim x As Integer = 10
For cntr As Integer = 0 To 10
newLabel.Parent = newPanel
newLabel.Dock = DockStyle.Top
newLabel.Tag = x
x = x - 1
newLabel.TextAlign = ContentAlignment.MiddleCenter
If cntr = 10 Then
newLabel.Font = New System.Drawing.Font("Times New Roman", 10, FontStyle.Bold)
Else
newLabel.Font = New System.Drawing.Font("Times New Roman", 10, FontStyle.Regular)
End If
newPanel.Controls.Add(newLabel)
Next
I am then opening form 2 that has 11 textboxes on it..... when the user clicks a button, the text of the textboxes is put into an array:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ctl As Control
Dim x As Integer
For Each ctl In Me.Controls
If ctl.GetType.ToString = "System.Windows.Forms.TextBox" Then
x = ctl.Tag
TableField(x) = ctl.Text
End If
Next
End Sub
I then close form2 and would like to get the text from the array and fill the labels that are in the panel. I currently have the following:
Dim ctl As Control
Dim lab As System.Windows.Forms.Label
For Each ctl In Me.Controls
If ctl.GetType.ToString = "System.Windows.Forms.Panel" Then
For Each lab In ctl.Controls
lab.Text = TableField(lab.Tag)
Next
End If
Next
The problem is that only the top label (Tag = 10) is getting filled up with text. I dont know if the problem is in the creation of the labels or when i fill them with text.
Please help
thanks
Private Sub DrawEntity(ByVal mouseDownPoint As System.Drawing.Point)
Dim panelSize As New System.Drawing.Size(150, 250)
Dim newPanel As New Panel
newPanel.Location = mouseDownPoint
newPanel.BorderStyle = BorderStyle.FixedSingle
newPanel.Size = panelSize
Me.Controls.Add(newPanel)
Dim newLabel As New Label
Dim x As Integer = 10
For cntr As Integer = 0 To 10
newLabel.Parent = newPanel
newLabel.Dock = DockStyle.Top
newLabel.Tag = x
x = x - 1
newLabel.TextAlign = ContentAlignment.MiddleCenter
If cntr = 10 Then
newLabel.Font = New System.Drawing.Font("Times New Roman", 10, FontStyle.Bold)
Else
newLabel.Font = New System.Drawing.Font("Times New Roman", 10, FontStyle.Regular)
End If
newPanel.Controls.Add(newLabel)
Next
I am then opening form 2 that has 11 textboxes on it..... when the user clicks a button, the text of the textboxes is put into an array:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ctl As Control
Dim x As Integer
For Each ctl In Me.Controls
If ctl.GetType.ToString = "System.Windows.Forms.TextBox" Then
x = ctl.Tag
TableField(x) = ctl.Text
End If
Next
End Sub
I then close form2 and would like to get the text from the array and fill the labels that are in the panel. I currently have the following:
Dim ctl As Control
Dim lab As System.Windows.Forms.Label
For Each ctl In Me.Controls
If ctl.GetType.ToString = "System.Windows.Forms.Panel" Then
For Each lab In ctl.Controls
lab.Text = TableField(lab.Tag)
Next
End If
Next
The problem is that only the top label (Tag = 10) is getting filled up with text. I dont know if the problem is in the creation of the labels or when i fill them with text.
Please help
thanks