//первая форма
Код:
Код: Выделить всё
BindingSource bns = new BindingSource();
private void companyDataGridView_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
//тут я получаю значение нужной мне строки
idcompany = Convert.ToString(this.companyDataGridView.Rows[this.companyDataGridView.CurrentCell.RowIndex].Cells[0].Value);
if (Convert.ToBoolean(companyDataGridView.Rows[this.companyDataGridView.CurrentCell.RowIndex].Cells[0].Value) == true)
{
bns.DataMember = this.companyDataGridView.DataMember;
bns.Position = companyDataGridView.CurrentRow.Index;
//Передай BindingSource во вторую форму
ZaprCompHistory.bns = bns;
// Дальше уже открывай вторую форму:
ZaprCompHistory zapros = new ZaprCompHistory();
zapros.Show();
}
}вторая форма
Код:
Код: Выделить всё
public static BindingSource bns { get; set; }
private void ZaprCompHistory_Load(object sender, EventArgs e)
{
this.textBox1.DataBindings.Clear();
textBox1.DataBindings.Add(new Binding("Text", bns, "Id_company"));
this.zapros_company_istoriyaTableAdapter.zapros(this.analyseDataSet.zapros_company_istoriya, textBox1.Text);
}