更新: 質問を変更したため、製品を更新するための更新版がここにあります
これはあなたの製品フォームです:
private frmMain main;
public frmSettings(frmMain mainForm)
{
main = mainForm;
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
main.AddProduct(textBox1.Text);
}
データを渡すには、コンストラクターにメインフォームが必要です。
そしてメインフォーム:
private frmSettings settings;
private List<string> products = new List<string>();
public frmMain()
{
InitializeComponent();
//load products from somewhere
}
private void button1_Click(object sender, EventArgs e)
{
if (settings == null)
{
settings = new frmSettings(this);
}
settings.Show();
}
private void UpdateForm()
{
comboBoxProducts.Items.Clear();
comboBoxProducts.Items.AddRange(products.ToArray());
//Other updates
}
public void AddProduct(string product)
{
products.Add(product);
UpdateForm();
}
UpdateForm()
次に、別のボタンなど、フォームのどこからでも呼び出すことができます。この例では、製品を格納するためにローカル変数のみを使用しています。製品を追加するための特定のチェックが欠けていることもありますが、あなたはその考えを理解していると思います...