私は2つの形式を持っています 最初のものはFrmReceiveItems
です。それで2番目のものを表示することができます FrmItemSearch
です。 2番目の方法では、最初の形式でDataGridView
に追加する項目を選択できます。問題は、アイテムを追加するたびに、最初のフォームから新しいオブジェクトが作成されることです。選択したすべてのアイテムを最初に開いたフォームに追加します。C#後ろの形の情報を取得する
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);
}
}
あなたの問題を説明する私たちに、最小限の完全かつ検証可能な例を示してください:http://stackoverflow.com/help/mcve – Fabjan