PC Review


Reply
Thread Tools Rate Thread

Can't Seem To Dynamically Generate Labels

 
 
Steven C
Guest
Posts: n/a
 
      31st Aug 2006
Hello:

I'm trying to dynamically generate some labels for a form, and I can't
seem to get it to work. The code is as follows. The first label is
generated, but subsequent labels are not. Is there a better technique
for this

for(int i=0; i <= intLabCount; i++)
{
strArrLabAccounts[i] = "lblCaption" + Convert.ToString(i).Trim();
Label lblNewLabel = new Label();
lblNewLabel.Parent = this.pgLiveView;
lblNewLabel.Text = "Yahoo" + Convert.ToString(i);
lblNewLabel.Location = new System.Drawing.Point(i*50,20);
lblNewLabel.Visible = true;
lblNewLabel.Name = strArrLabAccounts[i].ToString();
}

 
Reply With Quote
 
 
 
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      31st Aug 2006
Steven,

I think you overdo it, but at least I miss something as

Controls.Add(lblNewLabel);

Cor

"Steven C" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> Hello:
>
> I'm trying to dynamically generate some labels for a form, and I can't
> seem to get it to work. The code is as follows. The first label is
> generated, but subsequent labels are not. Is there a better technique
> for this
>
> for(int i=0; i <= intLabCount; i++)
> {
> strArrLabAccounts[i] = "lblCaption" + Convert.ToString(i).Trim();
> Label lblNewLabel = new Label();
> lblNewLabel.Parent = this.pgLiveView;
> lblNewLabel.Text = "Yahoo" + Convert.ToString(i);
> lblNewLabel.Location = new System.Drawing.Point(i*50,20);
> lblNewLabel.Visible = true;
> lblNewLabel.Name = strArrLabAccounts[i].ToString();
> }
>



 
Reply With Quote
 
Stoitcho Goutsev \(100\)
Guest
Posts: n/a
 
      31st Aug 2006
Steven,

I don't see anywhere in to code to add the labels to the form (or some other
control).

Could it be the the problem or you kust missed that line of code in the
snippet that you posted.
I find it strangle that you say the first label is only created.


--
HTH
Stoitcho Goutsev (100)

"Steven C" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello:
>
> I'm trying to dynamically generate some labels for a form, and I can't
> seem to get it to work. The code is as follows. The first label is
> generated, but subsequent labels are not. Is there a better technique
> for this
>
> for(int i=0; i <= intLabCount; i++)
> {
> strArrLabAccounts[i] = "lblCaption" + Convert.ToString(i).Trim();
> Label lblNewLabel = new Label();
> lblNewLabel.Parent = this.pgLiveView;
> lblNewLabel.Text = "Yahoo" + Convert.ToString(i);
> lblNewLabel.Location = new System.Drawing.Point(i*50,20);
> lblNewLabel.Visible = true;
> lblNewLabel.Name = strArrLabAccounts[i].ToString();
> }
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Generate a formula dynamically ? Jürgen Heyn Microsoft Excel Worksheet Functions 4 25th Sep 2007 06:43 PM
Dynamically generate form from XML & XSD? Scott Zabolotzky Microsoft ASP .NET 1 30th Aug 2006 01:41 AM
generate sub dynamically Christian Galbavy Microsoft Excel Programming 1 11th Mar 2005 04:19 PM
Generate menu dynamically Grey Microsoft ASP .NET 1 2nd Jun 2004 10:53 AM
Dynamically generate HTML in C# Rathtap Microsoft C# .NET 7 27th May 2004 01:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:45 AM.