【发布时间】:2020-12-05 21:21:21
【问题描述】:
我有两种表格:Form1 和 Form2。 Form1 包含一个文本框和一个搜索按钮。当我单击该按钮时,必须加载表格 2,然后在表格 1 中搜索到的那个人的姓名和家庭将显示在标签上。
通过我的代码,人的信息,在form1上显示,但不在form2上。
表格1:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
tbl1BindingSource.SuspendBinding();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'region1003660DataSet.Tbl1' table. You can move, or remove it, as needed.
this.tbl1TableAdapter.Fill(this.region1003660DataSet.Tbl1);
}
private void btnSearch_Click(object sender, EventArgs e)
{
MessageBox.Show(tbl1BindingSource.ToString());
int find = tbl1BindingSource.Find("id", txtSearch.Text);
if (find >= 0)
{
tbl1BindingSource.ResumeBinding();
tbl1BindingSource.Position = find;
}
else tbl1BindingSource.SuspendBinding();
Form2 f2 = new Form2(find);
f2.Show();
}
}
表格2:
public partial class Form2 : Form
{
public Form2(int f)
{
InitializeComponent();
tbl1BindingSource.SuspendBinding();
tbl1BindingSource.Position = f;
}
private void Form2_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'region1003660DataSet.Tbl1' table. You can move, or remove it, as needed.
this.tbl1TableAdapter.Fill(this.region1003660DataSet.Tbl1);
}
}
【问题讨论】:
标签: c# sql-server winforms modal-dialog