C
Chris.ry
Guest
Hi i have a combobox(used as a list of all my products) that has something like this Drink Water 1 (for category name and price) loaded from a text file ,so far i can place the columns but can only add one product ,after adding another with a button the previous gets replaced.
private void button2_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
{
dt.Columns.Add("Category");
dt.Columns.Add("Name");
dt.Columns.Add("Price");
}
string newline;
newline = comboBox1.Text;
DataRow dr = dt.NewRow();
string[] values = newline.Split( );
for (int i = 0; i < values.Length; i++)
{
dr = values;
}
dt.Rows.Add(dr);
dataGridView1.DataSource = dt;
}
Continue reading...
private void button2_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
{
dt.Columns.Add("Category");
dt.Columns.Add("Name");
dt.Columns.Add("Price");
}
string newline;
newline = comboBox1.Text;
DataRow dr = dt.NewRow();
string[] values = newline.Split( );
for (int i = 0; i < values.Length; i++)
{
dr = values;
}
dt.Rows.Add(dr);
dataGridView1.DataSource = dt;
}
Continue reading...