i want to create label automaticaly, ie i am try to printing some value into the form using label,
example...
in my form now i print a value using label, ie only one label in my form, if my program have more output, label have to create automatically,depend on the output
Loading
Rakesh JhaPosted Oct 4, 2010, 11:41 AM
{
Label one = new Label();
one.ForeColor = Color.White;
one.Text = line;
one.Left = 633;
one.Top = 250;
this.Controls.Add(one);
}
above code have no issue, it will add more label on your form but at same location. First you should understand this line
this.Controls.Add(one);
it means that, we are adding one label control to form control. So whether you want multiple label this code will work but in form you should set some systematic pattern for displaying those labels.
vishnu krishnanPosted Oct 4, 2010, 11:30 AM
in my project, just see this..
if (a1.Contains(line))
{
Label one = new Label();
one.ForeColor = Color.White;
one.Text = line;
one.Left = 633;
one.Top = 250;
this.Controls.Add(one);
}
here a1 is the arraylist and line is some string, so actually this string check with this arraylist, if that line in the arraylist, i have to print that,so if more string match with this arraylist have to create more label for print....
so what will print that?
Rakesh JhaPosted Oct 4, 2010, 11:23 AM
vishnu krishnanPosted Oct 4, 2010, 11:10 AM
Rakesh JhaPosted Oct 4, 2010, 10:58 AM
Label lblNewLabel = new Label();
lblNewLabel.Name = "lblNew";
lblNewLabel.Text = "Hello";
lblNewLabel.Left = 250;
lblNewLabel.Top = 250;
this.Controls.Add(lblNewLabel);