c# - this.Controls.Add() visibility = false -


when programmatically adding label during runtime in c#, label's visibility gets changed false after "this.controls.add(whatever), not true. idea how around this?

    public partial class form1 : form {     public form1()     {         initializecomponent();          label label = new label();         label.location = new point(15, 15);         label.text = "test";         label.autosize = true;         messagebox.show(convert.tostring(label.visible));         this.controls.add(label);         messagebox.show(convert.tostring(label.visible));     } } 

the first messagebox displays "true", while second messagebox displays "false"

you're adding label form hasn't been shown (yet), of course since entire form isn't visible, label on form isn't visible either.

when form shown, label become visible.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -