hello i have 2 datagridViews in a windows form and i have a combobox in 1 datagridview somwthing like this
when i change the value of the combobox the tables in the datagridview should be updated.For example if i select the second combobox as outputmetadatafield1 then the columns of that row should be updated with columns of 1st row in output metadata table.by i am not able the add a listener to the combobox as for dropdowns_selectedindexchanged.Can anyone tell m,e how to do that.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
load_input_table();
load_output_table();
}
static String conn = @"Data Source=SUMEET-PC\MSSQLSERVER1;Initial Catalog=EMIDS;Integrated Security=True";
SqlConnection connection = new SqlConnection(conn);
private void load_input_table()
{
String sql = "select * from input_metadata";
SqlDataAdapter adapter = new SqlDataAdapter(sql, connection);
DataTable table = new DataTable();
adapter.Fill(table);
BindingSource b = new BindingSource();
b.DataSource = table;
dataGridView1.DataSource = b;
addcombo();
}
private void addcombo()
{
DataGridViewComboBoxColumn inputtablecombobox = new DataGridViewComboBoxColumn();
inputtablecombobox.HeaderText = "field";
inputtablecombobox.Name = "inputtablecombobox";
String combosql = "select field from input_metadata";
SqlDataAdapter comboadapter = new SqlDataAdapter(combosql, connection);
DataSet ds = new DataSet();
comboadapter.Fill(ds);
inputtablecombobox.DataSource = ds.Tables[0];
inputtablecombobox.DisplayMember = "field";
inputtablecombobox.ValueMember = "field";
dataGridView1.Columns.Add(inputtablecombobox);
}
private void load_output_table()
{
String sql = "select * from output_metadata";
SqlDataAdapter adapter = new SqlDataAdapter(sql, connection);
DataTable table = new DataTable();
adapter.Fill(table);
BindingSource b = new BindingSource();
b.DataSource = table;
dataGridView2.DataSource = b;
}
private void inputtablecombobox_SelectedIndexChanged(object sender, EventArgs e)
{
MessageBox.Show("text");
}
}
thank you! i found the answer