c# - How do I change the content of a WinForms label from the Program.cs main method? -
so have start-up routine in main method checks make sure there content in .txt file.
fileinfo finfo = new fileinfo(datadir); if (finfo.length < 64) { //do stuff here if file not long enough }
i want able make label on winforms app display text , want grey out controls, can't seem find way reference said label/controls, or object in form matter. beginner, , struggling figure out.
if want able work form
object main()
method need pass in object instead of using new
keyword.
this see (visual studio produces code).
static class program { static void main() { application.enablevisualstyles(); application.setcompatibletextrenderingdefault(false); application.run(new form1()); } }
what can work form object.
static class program { static void main() { application.enablevisualstyles(); application.setcompatibletextrenderingdefault(false); form1 myform = new form1(); //create object here //you can work form here application.run(myform); //pass in form } }
Comments
Post a Comment