473,513 Members | 2,319 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't Seem To Dynamically Generate Labels

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();
}

Aug 31 '06 #1
2 1430
Steven,

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

Controls.Add(lblNewLabel);

Cor

"Steven C" <ch******@cox-internet.comschreef in bericht
news:11**********************@i3g2000cwc.googlegro ups.com...
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();
}

Aug 31 '06 #2
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" <ch******@cox-internet.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
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();
}

Aug 31 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2183
by: poisondart | last post by:
Is there a way to dynamically generate temporary files (such as an html, xml or text file) in Python? I'm not sure if I'm explaining myself clearly as I've no clue how to describe this...
3
1597
by: Gary | last post by:
I have a bunch of labels, and want to put in some container, which should be: 1. The number of labels for each column is fixed, say 16/row. And the number of currently displaying rows is fixed,...
2
3640
by: BillE | last post by:
I need to create a multi-line label dynamically. Since labels aren't multi-line, I'm creating a textbox and making it look like a label with the multiline property set to true. I want to...
4
7350
by: =?Utf-8?B?T2xhbg==?= | last post by:
Hi, I'm trying to dynamically remove labels from a windows form in csharp. I have a foreach loop similar to : foreach(Control c in this.Controls) { c.Dispose(); }
1
1139
by: ketaki | last post by:
Hello, I am facing a problem. I have a application in C# (winforms) where I am giving an option to the user to add labels during runtime. But when the application is restarted the labels that are...
2
1910
by: Sriku | last post by:
Hi Friends, i have page with few options. i need to generate multiple rows in page dynamically. in single row i have three labels and three select boxes, i need to get the number of row to be...
6
1434
by: python | last post by:
I need to generate multi-level incrementing labels for an outline/hierarchy where the string for each level of a label is based on an incrementing sequence like 1, 2, 3 or A, B, C, or even I, II,...
1
2299
by: bharathi228 | last post by:
hi, iam doing a windows application.i have a requirement like to create labels and textboxes dynamically at runtime.iam giving input as number of labels,and textboxes then it will created...
2
1831
by: | last post by:
Hi, I have 2 scenarios: First, an aspx page that contains 300 controls with the labels of course in a table. Second, an empty aspx page that contains on loading a script that creates the 300...
0
7269
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7394
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7559
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7542
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4756
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3248
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3237
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.