I am using Visual Studios to create a Windows form application. My system is in charge of creating and viewing module information for universities. However, currently though when my system boots it will fill the Tool Strip Menu I need a way of adding new items to this list when they are created. The new records are made on a different form and I cannot figure out how to add items to this ToolStripDropdown on Form 1 from the creating one of Form2 (see below for what it looks like). I have tried simply making the ToolStripMenuItem simply public but that does not work. Can anyone help me out?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace Mod_Note_2._0
{
public partial class Form2 : Form
{
public string newmodcode;
public string baseText = "Enter information related to the module section here";
public string newmodtitle;
public string newmodsyn;
public string newmodlo;
public string newmodassign;
public Form2()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
newmodcode = NewModuleCode.Text;
//Adds the file path and name to the module code to create the file names
newmodtitle = newmodcode + "title.txt";
newmodsyn = newmodcode + "synopsis.txt";
newmodlo = newmodcode + "LOs.txt";
newmodassign = newmodcode + "assignments.txt";
//Adds the file path the new module code so it can create the file
string newmodcodepath = newmodcode + "code.txt";
//Creates the new files with the filler text as default
File.WriteAllText(newmodcodepath, newmodcode);
File.WriteAllText(newmodtitle, baseText);
File.WriteAllText(newmodsyn, baseText);
File.WriteAllText(newmodlo, baseText);
File.WriteAllText(newmodassign, baseText);
Current code for adding items to the Drop down:
ToolStripItem newDropDownItem = new ToolStripMenuItem(); newDropDownItem.Text = newmodcode; Form1.modulesToolStripMenuItem.DropDownItems.Add(newDropDownItem);
Close();
}
//Simple cancelation sequence closing the entry form
private void button2_Click(object sender, EventArgs e)
{
Close();
}
}
}