c# - access form from usercontrol -
i have user control, needs access variables , static classes on form1.cs. can't find working illustration on google. hints please? thanks!
namespace winapp1 { public partial class form1 : form { public mycustomclass myclass; // need access public form1() { } } public static class global { public static myglobalvar; // need access } }
use this.parent
in usercontrol parent form :
form1 myparent = (form1)this.parent;
then can access public field/property :
myparent.myclass
note if usercontrol placed in panel within form, need parent of parent.
you can access static class name :
global.myglobalvar
c# user-controls
No comments:
Post a Comment