Nexusfactor
February 17th, 2010, 12:41 AM
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ShoppingListLib;
namespace ShoppingForms
{
public partial class Form2 : Form
{
private System.Windows.Forms.ComboBox[] comboBox = new ComboBox [9999];
private System.Windows.Forms.TextBox[] textBox = new TextBox [9999];
private string[] storeNameArray = { "Store A", "Store B", "Store C", "Store D", "Store E", "Store F", "Store G", "Store H",};
private string[] priceArray = new string[8];
public int store_num = 0;
public int box_location = 54;
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// comboBox1
//
this.comboBox[store_num] = new System.Windows.Forms.ComboBox();
this.comboBox[store_num].FormattingEnabl… = true;
this.comboBox[store_num].Location = new System.Drawing.Point(7, box_location );
this.comboBox[store_num].Name = "comboBox" ;
this.comboBox[store_num].Size = new System.Drawing.Size(68, 21);
this.comboBox[store_num].TabIndex = 0;
this.comboBox[store_num].DataSource = storeNameArray;
//
// textBox3
//
this.textBox[store_num] = new System.Windows.Forms.TextBox();
this.textBox[store_num].Location = new System.Drawing.Point(106, box_location);
this.textBox[store_num].Name = "textBox3";
this.textBox[store_num].Size = new System.Drawing.Size(76, 20);
this.textBox[store_num].TabIndex = 1;
priceArray[store_num] = this.textBox[store_num].SelectedText;
panel1.Controls.Add(this.comboBox[store_…
panel1.Controls.Add(this.textBox[store_n…
store_num += 1;
box_location += 20;
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
}
private void button2_Click(object sender, EventArgs e)
{
Product prod = new Product();
prod.Product_name = this.ProductBox.SelectedText ;
prod.Product_category = this.CategoryBox.SelectedText;
//prod.Temp_store[store_num] = storeNameArray[store_num];
//prod.Temp_price[store_num] = priceArray[store_num];
}
private void Form2_Load(object sender, EventArgs e)
{
}
}
}
I allow the user to add new ComboBoxes everytime they click add item. Now if there are two comboBoxes, when they select an item from the second one, it changes the first one as well. How do I stop that from happening, so each comboBox has there respective selections.
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ShoppingListLib;
namespace ShoppingForms
{
public partial class Form2 : Form
{
private System.Windows.Forms.ComboBox[] comboBox = new ComboBox [9999];
private System.Windows.Forms.TextBox[] textBox = new TextBox [9999];
private string[] storeNameArray = { "Store A", "Store B", "Store C", "Store D", "Store E", "Store F", "Store G", "Store H",};
private string[] priceArray = new string[8];
public int store_num = 0;
public int box_location = 54;
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// comboBox1
//
this.comboBox[store_num] = new System.Windows.Forms.ComboBox();
this.comboBox[store_num].FormattingEnabl… = true;
this.comboBox[store_num].Location = new System.Drawing.Point(7, box_location );
this.comboBox[store_num].Name = "comboBox" ;
this.comboBox[store_num].Size = new System.Drawing.Size(68, 21);
this.comboBox[store_num].TabIndex = 0;
this.comboBox[store_num].DataSource = storeNameArray;
//
// textBox3
//
this.textBox[store_num] = new System.Windows.Forms.TextBox();
this.textBox[store_num].Location = new System.Drawing.Point(106, box_location);
this.textBox[store_num].Name = "textBox3";
this.textBox[store_num].Size = new System.Drawing.Size(76, 20);
this.textBox[store_num].TabIndex = 1;
priceArray[store_num] = this.textBox[store_num].SelectedText;
panel1.Controls.Add(this.comboBox[store_…
panel1.Controls.Add(this.textBox[store_n…
store_num += 1;
box_location += 20;
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
}
private void button2_Click(object sender, EventArgs e)
{
Product prod = new Product();
prod.Product_name = this.ProductBox.SelectedText ;
prod.Product_category = this.CategoryBox.SelectedText;
//prod.Temp_store[store_num] = storeNameArray[store_num];
//prod.Temp_price[store_num] = priceArray[store_num];
}
private void Form2_Load(object sender, EventArgs e)
{
}
}
}
I allow the user to add new ComboBoxes everytime they click add item. Now if there are two comboBoxes, when they select an item from the second one, it changes the first one as well. How do I stop that from happening, so each comboBox has there respective selections.