You're getting a null because your active form is the one you're in and it is not of type frmMain. (I think you may actually be confusing an active form for a parent form?) There are so may ways to do this. You could make your frmMain a singleton but that's weird and ugly and not recommended of late or you could pass a reference of it to its children somehow. Here's one, simple way: Main Form: public partial class frmMain : Form { public frmMain () { InitializeComponent (); } // Main form private void MainFrm_Load ( object sender , EventArgs e ) { FormOrder frmO = new FormOrder ( this ); // pass a ref of self frmO . Show (); } public void Refresh () { // some action } } Sub Form: public partial class FormOrder : Form { private frmMain _parent ; // create a field that refers to the parent public FormOrder ( frmMain parent ) // mod the
Save Functions Project Structure (File Structure) UI BLL - Business Logic DAL- Data Access BE - Business Entity DB - DB Connection Class First Create a UI Frame and add the required Controls Then create a Java Class in BE Folder Generate Getter and Setter Methods Then Create a Java Class in DAL Package Write the following Insertion Code Then Create a Java Class in BLL Package It should return the DAL Class's method Finally write the Button click event We get the access file from the BLL package
Visual Studio Official Download page https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx Microsoft SQL Server official download page https://www.microsoft.com/en-us/download/details.aspx?id=29062
Comments
Post a Comment