Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>Try using a BindingSource BindingSource bindingSource = new BindingSource(); DataSet dataSet = new DataSet(); DataAdapter da1 = new DataAdapter("Select * from Customers", conn1); DataAdapter da2 = new DataAdapter("Select * form Orders", conn1); da1.Fill(dataSet,"Customers"); da2.Fill(dataSet,"Orders"); //Let we set Customers table as bindiningSource datasource bindingSource.DataSource = dataSet.Tables["Customers"]; private void RadioButtonCustomers_CheckedChanged(object sender, EventArgs e) { if(radioButtonCustomers.Checked==true) bindingSource.DataSource =dataSet.Tables["Customers"]; } private void RadioButtonOrders_CheckedChanged(object sender, EventArgs e) { if(radioButtonOrders.Checked==true) bindingSource.DataSource = dataSet.Tables["Orders"]; } //First param of Binding is to which prop of TextBox to bind the value //Second param is the data source //Third param is the data member or the column name of the table as datasource, so //we have to get that table from casting the bindingSource datasource prop and casting it //to DataTable obj and after that to take the ColumnName prop of the desired column textBox1.DataBindings.Add(new Binding("Text",bindingSource,((DataTable)bindingSource.DataSource).Columns[0].ColumnName)); textBox2.DataBindings.Add(new Binding("Text",bindingSource,((DataTable)bindingSource.DataSource).Columns[1].ColumnName)); etc... </code></pre> <p>Even if you change the datasource prop of bindingSource, textboxes will remain binded to rowvalue of first and second column</p> <p>Hope this help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload