C#在后台获取信息
我有两张表格 第一个是C#在后台获取信息,c#,forms,C#,Forms,我有两张表格 第一个是FrmReceiveItems,我可以从中显示第二个 FrmItemSearch。在第二个表单中,我可以选择要添加到第一个表单中的DataGridView。问题是,每当我添加一个项时,我都会从第一个表单中得到一个新对象。我希望所有选择的项目都添加到第一个打开的表单中。我试图测试是否打开了第一种形式的任何对象。。详情如下: private void dgv_ItemsSearch_CellContentClick(object sender, DataGridViewCell
FrmReceiveItems
,我可以从中显示第二个
FrmItemSearch
。在第二个表单中,我可以选择要添加到第一个表单中的DataGridView
。问题是,每当我添加一个项时,我都会从第一个表单中得到一个新对象。我希望所有选择的项目都添加到第一个打开的表单中。我试图测试是否打开了第一种形式的任何对象。。详情如下:
private void dgv_ItemsSearch_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
try
{
//Connection obj = new Connection();
//Connection.FrmChose = 10;
FrmRecieveItemsVoucher FRI = new FrmRecieveItemsVoucher();
Form frmT = Application.OpenForms["FRI"];
int value = Connection.FrmChose;
if (value == 10)
{
FRI.dataGridView_ItemsVoucher.Rows.Add();
int CurrentRowIndex = FRI.dataGridView_ItemsVoucher.Rows.Count;
FRI.dataGridView_ItemsVoucher.Rows[CurrentRowIndex - 1].Cells[0].Value = dgv_ItemsSearch.CurrentRow.Cells[2].Value;
FRI.dataGridView_ItemsVoucher.Rows[CurrentRowIndex - 1].Cells[1].Value = dgv_ItemsSearch.CurrentRow.Cells[1].Value;
// here I try to test
if (frmT != null)
{
this.Dispose();
}
else
{
FRI.Show();
}
}
else
{
FrmItems frmItems = new FrmItems();
//frmCust.btn_new(sender,e);
string Code = Convert.ToString(dgv_ItemsSearch.CurrentRow.Cells[2].Value);
this.Dispose();
frmItems.Show();
frmItems.Show_Record_data(Code);
}
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
实现这一点有很多方法。我个人的想法是创建一个
BindingList
并在该列表上设置一个ListChanged
事件,然后以第二种形式触发重新加载。请向我们展示一个最小、完整且可验证的示例,说明您的问题:好,下面的代码使用me var FrmRecieveItems=Application.OpenForms[“FrmRecieveItemsVoucher”]作为FrmRecieveItemsVoucher;