Okay, I have a menu Item that I only want to be enabled and visible if the user activates it through encryption key. My menu item is on a separate form than the encryption analysis and I can't figure out why it won't enable the item. It will pop up the message box and close the form when correct, and will also let you know when the key is incorrect. Below is my snippet that the analysis is located within.

Also please note that there are two string variables that are being used in this snippet but are declared as public strings at the top of the source just below the Initialize public.

public string pluginEncryption;
        public string pluginID;

        // This is a button click event.
        void analyzeEncryption(object sender, EventArgs myEvent)
            agDev.Properties.Settings mySettings = new agDev.Properties.Settings();
            agDev.Main myMain = new agDev.Main();

            pluginEncryption = key1.Text + "-" + key2.Text + "-" + key3.Text + "-" + key4.Text;
            pluginID = referenceID.Text;

            if (pluginEncryption == mySettings.myFirstPlugin)
                MessageBox.Show("Thank you for registering the plugin \"myFirstPlugin\".", "agDev");
                myMain.myFirstPluginToolStripMenuItem1.Visible = true;
                myMain.myFirstPluginToolStripMenuItem1.Enabled = true;

            else if (pluginEncryption != mySettings.myFirstPlugin)
                MessageBox.Show("Incorrect Encryption!", "agDev");
                myMain.myFirstPluginToolStripMenuItem1.Visible = false;
                myMain.myFirstPluginToolStripMenuItem1.Enabled = false;

Edited by lxXTaCoXxl: Added string declarations that are outside of snippet.

7 Years
Discussion Span
Last Post by lxXTaCoXxl

Line 8 you are creating a new main form then setting the visibility on that form. You never show that form and it vanishes when the current form closes.

You need an actual reference to the first form.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.