I have a combobox in my form and a datagridview. The datagridview contains 4 columns. I have bind one column to a database table's one column named 'item' which is filled after selecting value from combobox and i have added rest of 3 columns(quantity, price, total) by right clicking on datagridview design and by selecting "add columns" option. The problem is that on running code, the 'item' column appears in datagridview after the 3 columns I added. But I want this bind column to appear first and then the rest of 3 columns. Moreover , i also want to access all values from the column 'total'. Kindly suggest me how to do this. i have bind one column as:
public void populateGridView(string s)
{
string ConString = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
ConString = @"Data Source=.\SQLEXPRESS;AttachDbFilename= " + ConString + "\\ShopSoft\\ShopSoft\\Database2.mdf;Integrated Security=True;User Instance=True";
SqlConnection con = new SqlConnection(ConString);
con.Open();
string q = "select Item from SupplierItems where SupplierId ='" + s + "' ";
SqlDataAdapter da = new SqlDataAdapter(q, con);
DataTable dt1 = new DataTable();
da.Fill(dt1);
dataGridView1.DataSource = bsource;
bsource.DataSource = dt1;
con.Close();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
selectedVal = comboBox1.Text;
populateGridView(selectedVal);
}