CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: any mistake?

Threaded View

  1. #1
    Join Date
    Feb 2005
    Posts
    176

    [SOLVED] any mistake?

    on form click im creating a panel with 11 labels in it:
    Code:
    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:
    Code:
    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:
    Code:
    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
    Last edited by Nasty2; July 19th, 2005 at 01:27 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured