label.visible does not work

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm developing a quite comlex form containing a user control in C#

In the user control I'm trying to set a simple label to be visible:

labelState.Visible = true;

The debugger showns me, that the labelState.Visible is false
before entering this line of code.
But it is still false after this line of code!!!
Can anyone please explain, how this can happen?

I have double checked that I have not defined an event on this label that
resets the value to false.

Is there any posiible condition that does not allow to set a label's
visibility to true?

Regards

Burkhard Mahr

-------------------------
Label Initialization Code:
this.labelState.Anchor =
((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top |
System.Windows.Forms.AnchorStyles.Right)));

this.labelState.BackColor = System.Drawing.Color.Transparent;
this.labelState.Font = new System.Drawing.Font("Microsoft Sans Serif",
8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
this.labelState.Location = new System.Drawing.Point(870, 4);
this.labelState.Name = "labelState";
this.labelState.Size = new System.Drawing.Size(44, 16);
this.labelState.TabIndex = 16;
this.labelState.Text = "Status";
 
bugym said:
Is there any posiible condition that does not allow to set a label's
visibility to true?

If the label is not visible because its parent container is not visible (or
the form that contains the label is not visible), then setting its 'Visible'
property to 'True' doesn't have any effect, which means that the property
will still return 'False' until the control becomes visible.
 
Thanks a lot Herfried!
Your hint was the key to solve the problem.
Indeed I found a parent control that was not visible
Thanks & Regards
Burkhard
 
Back
Top