c# - Lables reading a text box -


this question has answer here:

can use label 1 form read data entered textbox on form? example entering number in text box , having information displayed label on other form

sure, it's not rough. general concept source form (where textbox resides) supplies necessary value destination form (where label resides). here small example:

sourceform:

namespace datatransferbetweenforms {     public partial class sourceform : form     {         public sourceform()         {             initializecomponent();         }          private void button1_click(object sender, eventargs e)         {             var destinationform = new destinationform();             destinationform.labeltext = textbox1.text;             destinationform.show();         }     } } 

destinationform:

namespace datatransferbetweenforms {     public partial class destinationform : form     {         public string labeltext         {             { return label1.text; }             set { label1.text = value; }         }          public destinationform()         {             initializecomponent();         }     } } 

now when sourceform's button1_click event triggered, instance of destinationform created, label's text property set, , destinationform instance shown.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -