Label not visible

  • Thread starter Thread starter Xarky
  • Start date Start date
X

Xarky

Hi,
I am trying to create a Label for a Windows Form, with my own code.
Its not being visible. The code being used is the following.

Label x = new Label();
x.Name = "node1";
x.Location = new System.Drawing.Point(200, 200);
x.Text = "Hello";
x.TabIndex = 1;
x.Show();
x.Refresh();


Can someone help.
Thanks
 
Hi Xarky,

You need to put the Label into a container control, for instance a windows
form.

this.Controls.Add(x);
 
Hi,

I think you got to add it to the place where you want it to be visible..
in ur case it seems that u want it to be displayed in the form..

so ...

Label x = new Label();
x.Name = "node1";
x.Location = new System.Drawing.Point(200, 200);
x.Text = "Hello";
x.TabIndex = 1;
this.Controls.add(x);

Nirosh.
 
Back
Top