CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2009
    Location
    Kathmandu,Nepal
    Posts
    168

    [RESOLVED] TextBoxes and Lables as an array????

    Hello! I have a simple query that suppose I have to put values on the lables from a array so instead of writing individual names for assigning values in lables from an array...can I treat Lables as Arrays so that i recogise them by its index for an example.....Here is unmanaged or untrue code....
    Code:
    label1= a[i];
    i++;
    label2=a[i];
    i++;
    label3=a[i];
    
    
    //So Instead Of above code  Is there any way to  Use the method of following example??
    for(i=0;i<9;i++)
    {
      label[i]=a[i];
    }

    Thanks......

  2. #2
    Join Date
    Jun 2008
    Posts
    2,477

    Re: TextBoxes and Lables as an array????

    Code:
    List<Label> labels = new List<Label>( );
    labels.Add( new Label( ) );
    labels.Add( new Label( ) );
    labels.Add( new Label( ) );
    int i = 1;
    foreach( Label label in labels )
    {
        label.Text = String.Format( "Label #{0}", i );
        ++i;
    }

  3. #3
    Join Date
    Dec 2009
    Location
    Kathmandu,Nepal
    Posts
    168

    Re: TextBoxes and Lables as an array????

    Thanks!!

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